@bkm016/basalt 0.1.12 → 0.1.13
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-7jezts2n.js → chunk-06s9pr82.js} +2 -2
- package/{chunk-jpnf71q7.js → chunk-095adzn5.js} +2 -2
- package/chunk-0a7ft50x.js +18 -0
- package/{chunk-vjne04dp.js → chunk-0nedq669.js} +4 -4
- package/chunk-0x9netvr.js +5 -0
- package/{chunk-9as0p561.js → chunk-15ve3nmv.js} +11 -11
- package/chunk-1dbfmejf.js +2 -0
- package/{chunk-hbnmymaq.js → chunk-1q6e3mj7.js} +2 -2
- package/{chunk-85v69h91.js → chunk-22az84sh.js} +2 -2
- package/{chunk-w0rr66z7.js → chunk-2q56egb8.js} +1 -1
- package/{chunk-fhxy6y34.js → chunk-2tf7qfbx.js} +2 -2
- package/{chunk-nw1xpt3s.js → chunk-2zbj8ny6.js} +2 -2
- package/chunk-302n9g7p.js +2 -0
- package/{chunk-bk4rpnm8.js → chunk-37ndxehw.js} +2 -2
- package/chunk-41das1ty.js +2 -0
- package/{chunk-6mges89p.js → chunk-44a7f5ta.js} +5 -5
- package/{chunk-jn5pqy5v.js → chunk-46vy2m29.js} +1 -1
- package/{chunk-1zj3zvw5.js → chunk-4k9t9jvx.js} +4 -4
- package/{chunk-eq4wqxzt.js → chunk-4rnmxtpx.js} +2 -2
- package/{chunk-1xfv4bd7.js → chunk-4w9zqv0k.js} +1 -1
- package/chunk-6d9r9p91.js +20 -0
- package/chunk-6f4ht2hw.js +2 -0
- package/{chunk-jj4hqbrx.js → chunk-6sea12mw.js} +3 -3
- package/chunk-74wwdx3y.js +3 -0
- package/{chunk-w6f2r052.js → chunk-77c2cqp2.js} +1 -1
- package/chunk-7chv3knf.js +2 -0
- package/chunk-86yr2c0r.js +3 -0
- package/{chunk-6sz5q3df.js → chunk-8cgz8xv7.js} +2 -2
- package/{chunk-tvm4zmgj.js → chunk-959z9efn.js} +2 -2
- package/{chunk-eyrtbbdd.js → chunk-9e8vhzy7.js} +1 -1
- package/chunk-b516bp7n.js +3 -0
- package/chunk-bja7p3em.js +25 -0
- package/chunk-bng72094.js +2 -0
- package/{chunk-ksk49hv0.js → chunk-bp61xdsc.js} +1 -1
- package/chunk-bq54argx.js +2 -0
- package/chunk-ct77cdg7.js +2 -0
- package/{chunk-02d3x4mj.js → chunk-dk6fgprw.js} +3 -3
- package/chunk-drett6hb.js +2 -0
- package/{chunk-4gtgqcct.js → chunk-edbq461k.js} +3 -3
- package/{chunk-p2pmdbt2.js → chunk-f0h2bv11.js} +12 -12
- package/{chunk-8mezk0cb.js → chunk-g2etemv5.js} +2 -2
- package/{chunk-n0ybj4h9.js → chunk-g5p9mj1r.js} +2 -2
- package/{chunk-fy82qxa1.js → chunk-gpnqmtbk.js} +1 -1
- package/{chunk-kpe7pnhy.js → chunk-h9zxqeqr.js} +4 -4
- package/{chunk-qfcr5g35.js → chunk-jjtt9aq8.js} +3 -3
- package/{chunk-5wnmbc1b.js → chunk-kbpbrr11.js} +2 -2
- package/chunk-m71pj3g1.js +2 -0
- package/chunk-mdkfm1ak.js +7 -0
- package/chunk-mf04h0yy.js +7 -0
- package/chunk-n22vd4at.js +2 -0
- package/{chunk-v7wcchy2.js → chunk-nbjnwd54.js} +1 -1
- package/{chunk-1h34mzh7.js → chunk-pryvvs96.js} +22 -22
- package/{chunk-2kxnw7vs.js → chunk-r1jn77q6.js} +2 -2
- package/{chunk-ypqjfv3a.js → chunk-rn3jwyh1.js} +2 -2
- package/chunk-sgrrxsnz.js +482 -0
- package/chunk-sgz87ht5.js +2 -0
- package/{chunk-stj493dn.js → chunk-snz19yc2.js} +2 -2
- package/{chunk-qs8zzg50.js → chunk-szj85dqe.js} +2 -2
- package/{chunk-nrsd810j.js → chunk-tfhp09nj.js} +2 -2
- package/{chunk-hc300148.js → chunk-tfhze1vq.js} +2 -2
- package/{chunk-01nve4qy.js → chunk-tjg0gcks.js} +1 -1
- package/{chunk-cbgpymt4.js → chunk-tnj2kqb8.js} +1 -1
- package/{chunk-3pf1d62g.js → chunk-vqm94hz2.js} +2 -2
- package/{chunk-82v8jh1h.js → chunk-xvm0y99b.js} +2 -2
- package/{chunk-rwks9zaw.js → chunk-y23dpz5e.js} +2 -2
- package/{chunk-ejjem0tc.js → chunk-y4pvhes1.js} +6 -6
- package/{chunk-bwawt15q.js → chunk-ydzag81d.js} +2 -2
- package/chunk-ymg7mtcx.js +3 -0
- package/chunk-yy1f9jxc.js +4044 -0
- package/{chunk-ntks40jd.js → chunk-z0c8ek0j.js} +5 -5
- package/chunk-zk91579b.js +3 -0
- package/{chunk-0fc9apfn.js → chunk-zx75vnw8.js} +18 -18
- package/compiled.js +85 -12
- package/package.json +1 -1
- package/ui-test-worker.js +53 -53
- package/web/{chunk-aeymdtm1.js → chunk-0jbf73pr.js} +3 -3
- package/web/{chunk-7vgh17es.js → chunk-0rhx7qb8.js} +1 -1
- package/web/{chunk-7adsmqv6.js → chunk-0rvwj2wh.js} +2 -2
- package/web/chunk-12qf1r6m.js +1 -0
- package/web/{chunk-dndd757x.js → chunk-14vmr99v.js} +3 -3
- package/web/{chunk-4f6a8dsk.js → chunk-16jc5m0f.js} +1 -1
- package/web/{chunk-bra33pt0.js → chunk-1m6fx2h7.js} +2 -2
- package/web/{chunk-hva7xyne.js → chunk-1xm9x7d6.js} +1 -1
- package/web/{chunk-8539865x.js → chunk-20jxvmbw.js} +1 -1
- package/web/chunk-2n5xbnrt.js +1 -0
- package/web/{chunk-bygwbpvq.js → chunk-2sef2wft.js} +2 -2
- package/web/{chunk-w9gnqkez.js → chunk-2x7vmhm0.js} +2 -2
- package/web/{chunk-19zd0tye.js → chunk-2y1avvqj.js} +8 -8
- package/web/chunk-36s08nye.js +1 -0
- package/web/chunk-3ctmehg4.js +1 -0
- package/web/{chunk-ncfzmf2g.js → chunk-3jjksgze.js} +1 -1
- package/web/{chunk-aebrw6cv.js → chunk-3p9w8sg5.js} +2 -2
- package/web/{chunk-sdr5wa4z.js → chunk-3wpxymxa.js} +3 -3
- package/web/{chunk-v34mr9ky.js → chunk-4py9sndw.js} +3 -3
- package/web/chunk-4swea9sn.js +1 -0
- package/web/chunk-4zz5a483.js +1 -0
- package/web/{chunk-3rkkp6ed.js → chunk-5cwxhhae.js} +5 -5
- package/web/{chunk-d57fm7k0.js → chunk-5ym5ffd5.js} +2 -2
- package/web/{chunk-gten0rpx.js → chunk-6e87m0nm.js} +2 -2
- package/web/{chunk-b99k8q22.js → chunk-6rsr2cyw.js} +8 -8
- package/web/chunk-6y55gk1n.js +1 -0
- package/web/chunk-7aep7k4v.js +1 -0
- package/web/{chunk-yf8ykk4v.js → chunk-8j4tzff5.js} +3 -3
- package/web/{chunk-ny436sqg.js → chunk-8tgavnwx.js} +1 -1
- package/web/{chunk-xvfeq8v2.js → chunk-97t3ngqf.js} +12 -12
- package/web/{chunk-gkmaryr4.js → chunk-980zhtht.js} +1 -1
- package/web/chunk-9k7fkx80.js +1 -0
- package/web/{chunk-hxbfkdjd.js → chunk-9wz8jne3.js} +1 -1
- package/web/chunk-a00vg115.js +1 -0
- package/web/chunk-a4gbxnm3.js +1 -0
- package/web/{chunk-6f2sz84q.js → chunk-a6g3nqp0.js} +1 -1
- package/web/{chunk-n9v14vyd.js → chunk-a9er7a7c.js} +22 -22
- package/web/chunk-atppv8fk.js +1 -0
- package/web/{chunk-xbyrgyy0.js → chunk-awkdw9rw.js} +2 -2
- package/web/{chunk-hqxc9m07.js → chunk-b4gcpsbg.js} +10 -10
- package/web/{chunk-qdd3bx8q.js → chunk-b9jry5a3.js} +1 -1
- package/web/{chunk-jyf7a7yp.js → chunk-ba9qy65y.js} +1 -1
- package/web/chunk-bq6mep6p.js +2 -0
- package/web/chunk-bwy3e58v.js +1 -0
- package/web/{chunk-aa46mrgh.js → chunk-c57f714b.js} +2 -2
- package/web/{chunk-b5zf1hs3.js → chunk-c6m4vfn5.js} +101 -101
- package/web/{chunk-5np514v5.js → chunk-cr04125j.js} +4 -4
- package/web/{chunk-ym7kv2hs.js → chunk-cr05dttm.js} +1 -1
- package/web/{chunk-2cyzaqjy.js → chunk-ct7z7bea.js} +3 -3
- package/web/{chunk-y2rzeb4v.js → chunk-ct90yf8z.js} +2 -2
- package/web/{chunk-yjs6jmdb.js → chunk-ddg8rz82.js} +3 -3
- package/web/{chunk-8cnjd0f2.js → chunk-dmha2y9c.js} +18 -18
- package/web/{chunk-jeafmjsm.js → chunk-e57h40qa.js} +6 -6
- package/web/chunk-eeesa5q1.js +1 -0
- package/web/{chunk-4wwd3pfz.js → chunk-eqndhs21.js} +2 -2
- package/web/{chunk-td83xf12.js → chunk-eqxy6535.js} +2 -2
- package/web/{chunk-wvrs986a.js → chunk-et1rsgmp.js} +3 -3
- package/web/chunk-f7jpakwh.js +1 -0
- package/web/{chunk-v1hfbjz9.js → chunk-fnvgdvrg.js} +4 -4
- package/web/chunk-fp62avjh.js +1 -0
- package/web/{chunk-6jb2zyp6.js → chunk-frnh4zqf.js} +2 -2
- package/web/chunk-g0be12na.js +1 -0
- package/web/{chunk-60mym60n.js → chunk-g7hqafb8.js} +1 -1
- package/web/{chunk-wqzbxzk3.js → chunk-ga07tv37.js} +1 -1
- package/web/chunk-gr163fex.js +1 -0
- package/web/chunk-gxtz10wf.js +1 -0
- package/web/{chunk-pjpre6de.js → chunk-h1k2kqbs.js} +6 -6
- package/web/{chunk-7tkgbbf9.js → chunk-h6k1x096.js} +2 -2
- package/web/{chunk-885kpj14.js → chunk-jccz14ye.js} +2 -2
- package/web/{chunk-d73zkc4q.js → chunk-jh33m2mq.js} +2 -2
- package/web/{chunk-g488hxx0.js → chunk-jh3k7xex.js} +3 -3
- package/web/{chunk-3qxxrwsp.js → chunk-jpem3qvs.js} +10 -10
- package/web/chunk-k9qnvx86.js +2 -0
- package/web/chunk-kcnj0gan.js +1 -0
- package/web/{chunk-2jfesv7m.js → chunk-ke8dffnk.js} +2 -2
- package/web/chunk-kpp5xqsb.js +1 -0
- package/web/chunk-m33yted6.js +1 -0
- package/web/chunk-me5jqqn6.js +1 -0
- package/web/{chunk-7v85yvb2.js → chunk-mkxeenph.js} +1 -1
- package/web/{chunk-mxkbmgcv.js → chunk-mnf4ngj9.js} +1 -1
- package/web/{chunk-30aeb767.js → chunk-mykrm8ba.js} +2 -2
- package/web/chunk-mzqqwbmr.js +1 -0
- package/web/chunk-npyrdsf8.css +1 -0
- package/web/chunk-p6e2vr51.js +34 -0
- package/web/{chunk-3n9ypydh.js → chunk-p7pa02k9.js} +2 -2
- package/web/chunk-q34as3v6.js +1 -0
- package/web/{chunk-7ksg3ccg.js → chunk-q4vy3dkk.js} +2 -2
- package/web/chunk-q6c8p73w.js +1 -0
- package/web/{chunk-h754ntg7.js → chunk-qb8mbptk.js} +1 -1
- package/web/{chunk-g4zm0crw.js → chunk-qbmtah1x.js} +1 -1
- package/web/chunk-qn93we3a.js +1 -0
- package/web/{chunk-c3fty2c2.js → chunk-qq06x2ce.js} +7 -7
- package/web/{chunk-fj753yzt.js → chunk-qq6m2my8.js} +2 -2
- package/web/chunk-r1f1egve.js +1 -0
- package/web/{chunk-80z8s8zb.js → chunk-s935z8er.js} +1 -1
- package/web/{chunk-3psgr0q8.js → chunk-sq75q603.js} +20 -20
- package/web/{chunk-qp3tjhaq.js → chunk-ss96cz1f.js} +1 -1
- package/web/{chunk-hn8m1vsg.js → chunk-t82sngk9.js} +7 -7
- package/web/chunk-tt9410zw.js +8 -0
- package/web/{chunk-act3rr85.js → chunk-v4cqc9f9.js} +1 -1
- package/web/chunk-ve8gy05p.js +1142 -0
- package/web/chunk-vg1ebkce.js +1 -0
- package/web/{chunk-k4dnjf8n.js → chunk-vk7ch6fh.js} +3 -3
- package/web/chunk-vnt34mkb.js +1 -0
- package/web/{chunk-kerfb21g.js → chunk-w28dn4dw.js} +1 -1
- package/web/{chunk-rdr6wt22.js → chunk-w4tfad6c.js} +4 -4
- package/web/{chunk-81s15c2e.js → chunk-wpxtkxjt.js} +2 -2
- package/web/{chunk-h24ybwp6.js → chunk-xcyqd7cn.js} +1 -1
- package/web/chunk-xe121vg7.js +1 -0
- package/web/chunk-xh4xn1az.js +1 -0
- package/web/{chunk-e94pd9rr.js → chunk-xk1vkcj4.js} +9 -9
- package/web/chunk-xrk5ewsn.js +1 -0
- package/web/{chunk-5g8md2wg.js → chunk-xvm66b7v.js} +4 -4
- package/web/{chunk-q1zxvjhs.js → chunk-xxmaqj1m.js} +2 -2
- package/web/chunk-xzwxcxb4.js +1 -0
- package/web/{chunk-xpecre7w.js → chunk-y9waq403.js} +4 -4
- package/web/chunk-ydhnkws0.js +1 -0
- package/web/{chunk-ar6jnhm5.js → chunk-yn4t5s9r.js} +1 -1
- package/web/chunk-ys2tns0p.js +1 -0
- package/web/chunk-zb61mf0a.js +1 -0
- package/web/{chunk-r6kk4vp1.js → chunk-ze6azq7z.js} +4 -4
- package/web/chunk-zh7193nq.js +2 -0
- package/web/chunk-zqcg6frm.js +1 -0
- package/web/{chunk-enwfd8d5.js → chunk-zxrbbbtp.js} +2 -2
- package/web/index.html +1 -1
- package/worker.js +1 -1
- package/chunk-2fyjph3f.js +0 -2
- package/chunk-37zystxb.js +0 -25
- package/chunk-3k627vf2.js +0 -3
- package/chunk-7er5pz7s.js +0 -479
- package/chunk-7g5smgjj.js +0 -2
- package/chunk-7m3jagqn.js +0 -2
- package/chunk-9c4gdg1q.js +0 -3
- package/chunk-b2bxqeb4.js +0 -2
- package/chunk-bpw6q7g0.js +0 -3
- package/chunk-cdw03j4t.js +0 -20
- package/chunk-ch1r3ted.js +0 -2
- package/chunk-cmwdjes8.js +0 -18
- package/chunk-db7ws33a.js +0 -7
- package/chunk-e1x629v0.js +0 -5
- package/chunk-j64dc767.js +0 -3
- package/chunk-m4bg1apa.js +0 -7
- package/chunk-nhm9z3d8.js +0 -2
- package/chunk-pnspvnyd.js +0 -2
- package/chunk-qnkrrwmg.js +0 -2
- package/chunk-r4gm8ngh.js +0 -2
- package/chunk-rks90mh1.js +0 -2
- package/chunk-t7te60m7.js +0 -2
- package/chunk-tv52xajf.js +0 -2
- package/chunk-wqqjzsjt.js +0 -3983
- package/chunk-xef4642x.js +0 -3
- package/web/chunk-04drx71p.js +0 -1
- package/web/chunk-0mdf1qja.js +0 -1
- package/web/chunk-0rdgt4jb.css +0 -1
- package/web/chunk-1m0kp0g3.js +0 -8
- package/web/chunk-3j2tcphs.js +0 -1
- package/web/chunk-3k9h7a73.js +0 -1142
- package/web/chunk-3m1bb2fw.js +0 -1
- package/web/chunk-55nvm2mj.js +0 -1
- package/web/chunk-5dkqfnh7.js +0 -2
- package/web/chunk-7ky5nrrr.js +0 -1
- package/web/chunk-8sdjgv3k.js +0 -1
- package/web/chunk-9bxtzwtc.js +0 -1
- package/web/chunk-9jy8nc4r.js +0 -1
- package/web/chunk-bcjgzwef.js +0 -1
- package/web/chunk-cxpnj495.js +0 -2
- package/web/chunk-d1btrqmw.js +0 -1
- package/web/chunk-d94t9z70.js +0 -1
- package/web/chunk-e68jw0bg.js +0 -1
- package/web/chunk-fr4fft89.js +0 -1
- package/web/chunk-gckmcef6.js +0 -1
- package/web/chunk-gnb09wmx.js +0 -1
- package/web/chunk-hrgqc1vr.js +0 -1
- package/web/chunk-j9c8fa82.js +0 -1
- package/web/chunk-jz5mmp64.js +0 -1
- package/web/chunk-kxeaj44h.js +0 -1
- package/web/chunk-m0136xav.js +0 -1
- package/web/chunk-m1rdyvb5.js +0 -1
- package/web/chunk-m6vyvgm5.js +0 -1
- package/web/chunk-my0ec787.js +0 -1
- package/web/chunk-nkpdd9hw.js +0 -1
- package/web/chunk-pbp1p5ex.js +0 -1
- package/web/chunk-ph75hddv.js +0 -1
- package/web/chunk-phdfyqaa.js +0 -1
- package/web/chunk-phxa5krt.js +0 -1
- package/web/chunk-r4zbw4zj.js +0 -2
- package/web/chunk-ry4ycah9.js +0 -1
- package/web/chunk-sqm16fat.js +0 -1
- package/web/chunk-tj1fn8v2.js +0 -1
- package/web/chunk-v0wtk059.js +0 -34
- package/web/chunk-v1qt3gq4.js +0 -1
- package/web/chunk-v854w9yn.js +0 -1
- package/web/chunk-ve56gxq0.js +0 -1
- package/web/chunk-w573ym17.js +0 -1
- package/web/chunk-x0mjydtp.js +0 -1
- package/web/chunk-zhybh04p.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o,
|
|
1
|
+
import{o,W,i,r,m,e,n,y,te,ne}from"./chunk-ve8gy05p.js";import{na}from"./chunk-k9qnvx86.js";var A=[{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 L(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 z(t,c,u){let p=L(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 F({notice:t}){let{cn:c}=y();if(!t)return null;let u=t.type==="success"?na: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=W(),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:"失败时依次切换渠道"},...A.map((s)=>({value:s.id,label:s.name}))]}],onValueChange:(s)=>{let a=s==="auto"?s:A.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(ne,{className:w("size-3.5",t.checking==="all"&&"animate-spin"),"aria-hidden":"true"}),t.checking==="all"?"正在检测…":"全部检测"]}),children:A.map((s)=>{let a=s.id,k=a==="searxng"?void 0:t.saved.keys[a],K=k?.source==="environment",D=a==="searxng"?void 0:t.keys[a],h=D==="",v=t.checks[a],E=t.checking==="all"||t.checking===a,f=k?.configured?"已配置密钥":"未配置";if(a==="searxng")f=t.saved.search.searxngUrl?"已配置地址":"未配置地址";if(K)f="来自环境变量";if(h)f="待移除";if(D)f="待保存密钥";let U=v&&!v.ok&&!E?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&&" · 请在服务端环境变量中更换或移除",U&&e("span",{role:"status",className:"block break-words text-danger",children:U})]}),children:[E?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",D!==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(F,{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({}),[D,h]=r(),[v,E]=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(L(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 U(){if(f.current||!u||!x||!z(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(L(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 B=await t.request(`/api/plugins/webfetch/test?provider=${d}`,{method:"POST",signal:g.signal});if(g.signal.aborted)return;K((M)=>{let G={...M};for(let T of B.checks)if(T.kind==="search"&&T.provider)G[T.provider]=T;return G})}catch(B){if(!g.signal.aborted)h({type:"error",text:B instanceof Error?B.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(F,{notice:D}),b!=="load"&&e(c,{type:"button",size:"sm",variant:"ghost",onClick:()=>E(v+1),children:"重新加载"})]});return e(q,{saved:u,draft:x,keys:R,editingKey:C,dirty:z(u,x,R),busy:b==="load"?void 0:b,checking:s,checks:k,notice:D,onDraft:(d)=>{S(d),h(void 0)},onKeys:(d)=>{P(d),h(void 0)},onEditKey:w,onSave:U,onCheck:N,onRestore:()=>{S(L(u)),P({}),w(void 0),h(void 0)}})}export{O as default};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{t,a,Re,b,C,S,E,T,A,L,R,l,p,
|
|
1
|
+
import{t,a,Re,b,C,S,E,T,A,L,R,l,p,Yi,M,pe,le,ce,yt,ge,ye}from"./chunk-c6m4vfn5.js";import{Ft}from"./chunk-ke8dffnk.js";import{he}from"./chunk-mkxeenph.js";import{ue}from"./chunk-b9jry5a3.js";var Bt=function(){var e=t(function(Q,h,g,n){for(g=g||{},n=Q.length;n--;g[Q[n]]=h);return g},"o"),s=[1,2],c=[1,3],r=[1,4],u=[2,4],f=[1,9],m=[1,11],k=[1,16],o=[1,17],D=[1,18],x=[1,19],G=[1,33],Y=[1,20],j=[1,21],O=[1,22],y=[1,23],V=[1,24],F=[1,26],z=[1,27],W=[1,28],K=[1,29],N=[1,30],st=[1,31],pt=[1,32],St=[1,35],gt=[1,36],mt=[1,37],bt=[1,38],rt=[1,34],_=[1,4,5,16,17,19,21,22,24,25,26,27,28,29,33,35,37,38,41,45,48,51,52,53,54,57],kt=[1,4,5,14,15,16,17,19,21,22,24,25,26,27,28,29,33,35,37,38,39,40,41,45,48,51,52,53,54,57],Mt=[4,5,16,17,19,21,22,24,25,26,27,28,29,33,35,37,38,41,45,48,51,52,53,54,57],Lt={trace:t(function(){},"trace"),yy:{},symbols_:{error:2,start:3,SPACE:4,NL:5,SD:6,document:7,line:8,statement:9,classDefStatement:10,styleStatement:11,cssClassStatement:12,idStatement:13,DESCR:14,"-->":15,HIDE_EMPTY:16,scale:17,WIDTH:18,COMPOSIT_STATE:19,STRUCT_START:20,STRUCT_STOP:21,STATE_DESCR:22,AS:23,ID:24,FORK:25,JOIN:26,CHOICE:27,CONCURRENT:28,note:29,notePosition:30,NOTE_TEXT:31,direction:32,acc_title:33,acc_title_value:34,acc_descr:35,acc_descr_value:36,acc_descr_multiline_value:37,CLICK:38,STRING:39,HREF:40,classDef:41,CLASSDEF_ID:42,CLASSDEF_STYLEOPTS:43,DEFAULT:44,style:45,STYLE_IDS:46,STYLEDEF_STYLEOPTS:47,class:48,CLASSENTITY_IDS:49,STYLECLASS:50,direction_tb:51,direction_bt:52,direction_rl:53,direction_lr:54,eol:55,";":56,EDGE_STATE:57,STYLE_SEPARATOR:58,left_of:59,right_of:60,$accept:0,$end:1},terminals_:{2:"error",4:"SPACE",5:"NL",6:"SD",14:"DESCR",15:"-->",16:"HIDE_EMPTY",17:"scale",18:"WIDTH",19:"COMPOSIT_STATE",20:"STRUCT_START",21:"STRUCT_STOP",22:"STATE_DESCR",23:"AS",24:"ID",25:"FORK",26:"JOIN",27:"CHOICE",28:"CONCURRENT",29:"note",31:"NOTE_TEXT",33:"acc_title",34:"acc_title_value",35:"acc_descr",36:"acc_descr_value",37:"acc_descr_multiline_value",38:"CLICK",39:"STRING",40:"HREF",41:"classDef",42:"CLASSDEF_ID",43:"CLASSDEF_STYLEOPTS",44:"DEFAULT",45:"style",46:"STYLE_IDS",47:"STYLEDEF_STYLEOPTS",48:"class",49:"CLASSENTITY_IDS",50:"STYLECLASS",51:"direction_tb",52:"direction_bt",53:"direction_rl",54:"direction_lr",56:";",57:"EDGE_STATE",58:"STYLE_SEPARATOR",59:"left_of",60:"right_of"},productions_:[0,[3,2],[3,2],[3,2],[7,0],[7,2],[8,2],[8,1],[8,1],[9,1],[9,1],[9,1],[9,1],[9,2],[9,3],[9,4],[9,1],[9,2],[9,1],[9,4],[9,3],[9,6],[9,1],[9,1],[9,1],[9,1],[9,4],[9,4],[9,1],[9,2],[9,2],[9,1],[9,5],[9,5],[10,3],[10,3],[11,3],[12,3],[32,1],[32,1],[32,1],[32,1],[55,1],[55,1],[13,1],[13,1],[13,3],[13,3],[30,1],[30,1]],performAction:t(function(h,g,n,v,w,i,it){var d=i.length-1;switch(w){case 3:return v.setRootDoc(i[d]),i[d];break;case 4:this.$=[];break;case 5:if(i[d]!="nl")i[d-1].push(i[d]),this.$=i[d-1];break;case 6:case 7:this.$=i[d];break;case 8:this.$="nl";break;case 12:this.$=i[d];break;case 13:let Et=i[d-1];Et.description=v.trimColon(i[d]),this.$=Et;break;case 14:this.$={stmt:"relation",state1:i[d-2],state2:i[d]};break;case 15:let _t=v.trimColon(i[d]);this.$={stmt:"relation",state1:i[d-3],state2:i[d-1],description:_t};break;case 19:this.$={stmt:"state",id:i[d-3],type:"default",description:"",doc:i[d-1]};break;case 20:var X=i[d],J=i[d-2].trim();if(i[d].match(":")){var lt=i[d].split(":");X=lt[0],J=[J,lt[1]]}this.$={stmt:"state",id:X,type:"default",description:J};break;case 21:this.$={stmt:"state",id:i[d-3],type:"default",description:i[d-5],doc:i[d-1]};break;case 22:this.$={stmt:"state",id:i[d],type:"fork"};break;case 23:this.$={stmt:"state",id:i[d],type:"join"};break;case 24:this.$={stmt:"state",id:i[d],type:"choice"};break;case 25:this.$={stmt:"state",id:v.getDividerId(),type:"divider"};break;case 26:this.$={stmt:"state",id:i[d-1].trim(),note:{position:i[d-2].trim(),text:i[d].trim()}};break;case 29:this.$=i[d].trim(),v.setAccTitle(this.$);break;case 30:case 31:this.$=i[d].trim(),v.setAccDescription(this.$);break;case 32:this.$={stmt:"click",id:i[d-3],url:i[d-2],tooltip:i[d-1]};break;case 33:this.$={stmt:"click",id:i[d-3],url:i[d-1],tooltip:""};break;case 34:case 35:this.$={stmt:"classDef",id:i[d-1].trim(),classes:i[d].trim()};break;case 36:this.$={stmt:"style",id:i[d-1].trim(),styleClass:i[d].trim()};break;case 37:this.$={stmt:"applyClass",id:i[d-1].trim(),styleClass:i[d].trim()};break;case 38:v.setDirection("TB"),this.$={stmt:"dir",value:"TB"};break;case 39:v.setDirection("BT"),this.$={stmt:"dir",value:"BT"};break;case 40:v.setDirection("RL"),this.$={stmt:"dir",value:"RL"};break;case 41:v.setDirection("LR"),this.$={stmt:"dir",value:"LR"};break;case 44:case 45:this.$={stmt:"state",id:i[d].trim(),type:"default",description:""};break;case 46:this.$={stmt:"state",id:i[d-2].trim(),classes:[i[d].trim()],type:"default",description:""};break;case 47:this.$={stmt:"state",id:i[d-2].trim(),classes:[i[d].trim()],type:"default",description:""};break}},"anonymous"),table:[{3:1,4:s,5:c,6:r},{1:[3]},{3:5,4:s,5:c,6:r},{3:6,4:s,5:c,6:r},e([1,4,5,16,17,19,22,24,25,26,27,28,29,33,35,37,38,41,45,48,51,52,53,54,57],u,{7:7}),{1:[2,1]},{1:[2,2]},{1:[2,3],4:f,5:m,8:8,9:10,10:12,11:13,12:14,13:15,16:k,17:o,19:D,22:x,24:G,25:Y,26:j,27:O,28:y,29:V,32:25,33:F,35:z,37:W,38:K,41:N,45:st,48:pt,51:St,52:gt,53:mt,54:bt,57:rt},e(_,[2,5]),{9:39,10:12,11:13,12:14,13:15,16:k,17:o,19:D,22:x,24:G,25:Y,26:j,27:O,28:y,29:V,32:25,33:F,35:z,37:W,38:K,41:N,45:st,48:pt,51:St,52:gt,53:mt,54:bt,57:rt},e(_,[2,7]),e(_,[2,8]),e(_,[2,9]),e(_,[2,10]),e(_,[2,11]),e(_,[2,12],{14:[1,40],15:[1,41]}),e(_,[2,16]),{18:[1,42]},e(_,[2,18],{20:[1,43]}),{23:[1,44]},e(_,[2,22]),e(_,[2,23]),e(_,[2,24]),e(_,[2,25]),{30:45,31:[1,46],59:[1,47],60:[1,48]},e(_,[2,28]),{34:[1,49]},{36:[1,50]},e(_,[2,31]),{13:51,24:G,57:rt},{42:[1,52],44:[1,53]},{46:[1,54]},{49:[1,55]},e(kt,[2,44],{58:[1,56]}),e(kt,[2,45],{58:[1,57]}),e(_,[2,38]),e(_,[2,39]),e(_,[2,40]),e(_,[2,41]),e(_,[2,6]),e(_,[2,13]),{13:58,24:G,57:rt},e(_,[2,17]),e(Mt,u,{7:59}),{24:[1,60]},{24:[1,61]},{23:[1,62]},{24:[2,48]},{24:[2,49]},e(_,[2,29]),e(_,[2,30]),{39:[1,63],40:[1,64]},{43:[1,65]},{43:[1,66]},{47:[1,67]},{50:[1,68]},{24:[1,69]},{24:[1,70]},e(_,[2,14],{14:[1,71]}),{4:f,5:m,8:8,9:10,10:12,11:13,12:14,13:15,16:k,17:o,19:D,21:[1,72],22:x,24:G,25:Y,26:j,27:O,28:y,29:V,32:25,33:F,35:z,37:W,38:K,41:N,45:st,48:pt,51:St,52:gt,53:mt,54:bt,57:rt},e(_,[2,20],{20:[1,73]}),{31:[1,74]},{24:[1,75]},{39:[1,76]},{39:[1,77]},e(_,[2,34]),e(_,[2,35]),e(_,[2,36]),e(_,[2,37]),e(kt,[2,46]),e(kt,[2,47]),e(_,[2,15]),e(_,[2,19]),e(Mt,u,{7:78}),e(_,[2,26]),e(_,[2,27]),{5:[1,79]},{5:[1,80]},{4:f,5:m,8:8,9:10,10:12,11:13,12:14,13:15,16:k,17:o,19:D,21:[1,81],22:x,24:G,25:Y,26:j,27:O,28:y,29:V,32:25,33:F,35:z,37:W,38:K,41:N,45:st,48:pt,51:St,52:gt,53:mt,54:bt,57:rt},e(_,[2,32]),e(_,[2,33]),e(_,[2,21])],defaultActions:{5:[2,1],6:[2,2],47:[2,48],48:[2,49]},parseError:t(function(h,g){if(g.recoverable)this.trace(h);else{var n=Error(h);throw n.hash=g,n}},"parseError"),parse:t(function(h){var g=this,n=[0],v=[],w=[null],i=[],it=this.table,d="",X=0,J=0,lt=0,Et=2,_t=1,be=i.slice.call(arguments,1),I=Object.create(this.lexer),tt={yy:{}};for(var wt in this.yy)if(Object.prototype.hasOwnProperty.call(this.yy,wt))tt.yy[wt]=this.yy[wt];if(I.setInput(h,tt.yy),tt.yy.lexer=I,tt.yy.parser=this,typeof I.yylloc>"u")I.yylloc={};var It=I.yylloc;i.push(It);var ke=I.options&&I.options.ranges;if(typeof tt.yy.parseError==="function")this.parseError=tt.yy.parseError;else this.parseError=Object.getPrototypeOf(this).parseError;function Te(H){n.length=n.length-2*H,w.length=w.length-H,i.length=i.length-H}t(Te,"popStack");function Wt(){var H=v.pop()||I.lex()||_t;if(typeof H!=="number"){if(H instanceof Array)v=H,H=v.pop();H=g.symbols_[H]||H}return H}t(Wt,"lex");var P,Nt,et,U,ts,Ot,at={},vt,q,jt,Dt;while(!0){if(et=n[n.length-1],this.defaultActions[et])U=this.defaultActions[et];else{if(P===null||typeof P>"u")P=Wt();U=it[et]&&it[et][P]}if(typeof U>"u"||!U.length||!U[0]){var Rt="";Dt=[];for(vt in it[et])if(this.terminals_[vt]&&vt>Et)Dt.push("'"+this.terminals_[vt]+"'");if(I.showPosition)Rt="Parse error on line "+(X+1)+`:
|
|
2
2
|
`+I.showPosition()+`
|
|
3
|
-
Expecting `+Dt.join(", ")+", got '"+(this.terminals_[
|
|
3
|
+
Expecting `+Dt.join(", ")+", got '"+(this.terminals_[P]||P)+"'";else Rt="Parse error on line "+(X+1)+": Unexpected "+(P==_t?"end of input":"'"+(this.terminals_[P]||P)+"'");this.parseError(Rt,{text:I.match,token:this.terminals_[P]||P,line:I.yylineno,loc:It,expected:Dt})}if(U[0]instanceof Array&&U.length>1)throw Error("Parse Error: multiple actions possible at state: "+et+", token: "+P);switch(U[0]){case 1:if(n.push(P),w.push(I.yytext),i.push(I.yylloc),n.push(U[1]),P=null,!Nt){if(J=I.yyleng,d=I.yytext,X=I.yylineno,It=I.yylloc,lt>0)lt--}else P=Nt,Nt=null;break;case 2:if(q=this.productions_[U[1]][1],at.$=w[w.length-q],at._$={first_line:i[i.length-(q||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(q||1)].first_column,last_column:i[i.length-1].last_column},ke)at._$.range=[i[i.length-(q||1)].range[0],i[i.length-1].range[1]];if(Ot=this.performAction.apply(at,[d,J,X,tt.yy,U[1],w,i].concat(be)),typeof Ot<"u")return Ot;if(q)n=n.slice(0,-1*q*2),w=w.slice(0,-1*q),i=i.slice(0,-1*q);n.push(this.productions_[U[1]][0]),w.push(at.$),i.push(at._$),jt=it[n[n.length-2]][n[n.length-1]],n.push(jt);break;case 3:return!0}}return!0},"parse")},me=function(){var Q={EOF:1,parseError:t(function(g,n){if(this.yy.parser)this.yy.parser.parseError(g,n);else throw Error(g)},"parseError"),setInput:t(function(h,g){if(this.yy=g||this.yy||{},this._input=h,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges)this.yylloc.range=[0,0];return this.offset=0,this},"setInput"),input:t(function(){var h=this._input[0];this.yytext+=h,this.yyleng++,this.offset++,this.match+=h,this.matched+=h;var g=h.match(/(?:\r\n?|\n).*/g);if(g)this.yylineno++,this.yylloc.last_line++;else this.yylloc.last_column++;if(this.options.ranges)this.yylloc.range[1]++;return this._input=this._input.slice(1),h},"input"),unput:t(function(h){var g=h.length,n=h.split(/(?:\r\n?|\n)/g);this._input=h+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-g),this.offset-=g;var v=this.match.split(/(?:\r\n?|\n)/g);if(this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1)this.yylineno-=n.length-1;var w=this.yylloc.range;if(this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===v.length?this.yylloc.first_column:0)+v[v.length-n.length].length-n[0].length:this.yylloc.first_column-g},this.options.ranges)this.yylloc.range=[w[0],w[0]+this.yyleng-g];return this.yyleng=this.yytext.length,this},"unput"),more:t(function(){return this._more=!0,this},"more"),reject:t(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:t(function(h){this.unput(this.match.slice(h))},"less"),pastInput:t(function(){var h=this.matched.substr(0,this.matched.length-this.match.length);return(h.length>20?"...":"")+h.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:t(function(){var h=this.match;if(h.length<20)h+=this._input.substr(0,20-h.length);return(h.substr(0,20)+(h.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:t(function(){var h=this.pastInput(),g=Array(h.length+1).join("-");return h+this.upcomingInput()+`
|
|
5
5
|
`+g+"^"},"showPosition"),test_match:t(function(h,g){var n,v,w;if(this.options.backtrack_lexer){if(w={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges)w.yylloc.range=this.yylloc.range.slice(0)}if(v=h[0].match(/(?:\r\n?|\n).*/g),v)this.yylineno+=v.length;if(this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:v?v[v.length-1].length-v[v.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+h[0].length},this.yytext+=h[0],this.match+=h[0],this.matches=h,this.yyleng=this.yytext.length,this.options.ranges)this.yylloc.range=[this.offset,this.offset+=this.yyleng];if(this._more=!1,this._backtrack=!1,this._input=this._input.slice(h[0].length),this.matched+=h[0],n=this.performAction.call(this,this.yy,this,g,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input)this.done=!1;if(n)return n;else if(this._backtrack){for(var i in w)this[i]=w[i];return!1}return!1},"test_match"),next:t(function(){if(this.done)return this.EOF;if(!this._input)this.done=!0;var h,g,n,v;if(!this._more)this.yytext="",this.match="";var w=this._currentRules();for(var i=0;i<w.length;i++)if(n=this._input.match(this.rules[w[i]]),n&&(!g||n[0].length>g[0].length)){if(g=n,v=i,this.options.backtrack_lexer)if(h=this.test_match(n,w[i]),h!==!1)return h;else if(this._backtrack){g=!1;continue}else return!1;else if(!this.options.flex)break}if(g){if(h=this.test_match(g,w[v]),h!==!1)return h;return!1}if(this._input==="")return this.EOF;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
6
|
-
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:t(function(){var g=this.next();if(g)return g;else return this.lex()},"lex"),begin:t(function(g){this.conditionStack.push(g)},"begin"),popState:t(function(){var g=this.conditionStack.length-1;if(g>0)return this.conditionStack.pop();else return this.conditionStack[0]},"popState"),_currentRules:t(function(){if(this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1])return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;else return this.conditions.INITIAL.rules},"_currentRules"),topState:t(function(g){if(g=this.conditionStack.length-1-Math.abs(g||0),g>=0)return this.conditionStack[g];else return"INITIAL"},"topState"),pushState:t(function(g){this.begin(g)},"pushState"),stateStackSize:t(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:t(function(g,n,v,w){function i(){let d=n.yytext.indexOf("%%");if(d===0)return!1;if(d>0){let X=n.yytext.slice(0,d),J=n.yytext.slice(d);if(J)g.lexer.unput(J);n.yytext=X}return!0}t(i,"processId");var it=w;switch(v){case 0:return 38;case 1:return 40;case 2:return 39;case 3:return 44;case 4:return 51;case 5:return 52;case 6:return 53;case 7:return 54;case 8:return 5;case 9:break;case 10:break;case 11:break;case 12:break;case 13:return this.pushState("SCALE"),17;break;case 14:return 18;case 15:this.popState();break;case 16:return this.begin("acc_title"),33;break;case 17:return this.popState(),"acc_title_value";break;case 18:return this.begin("acc_descr"),35;break;case 19:return this.popState(),"acc_descr_value";break;case 20:this.begin("acc_descr_multiline");break;case 21:this.popState();break;case 22:return"acc_descr_multiline_value";case 23:return this.pushState("CLASSDEF"),41;break;case 24:return this.popState(),this.pushState("CLASSDEFID"),"DEFAULT_CLASSDEF_ID";break;case 25:return this.popState(),this.pushState("CLASSDEFID"),42;break;case 26:return this.popState(),43;break;case 27:return this.pushState("CLASS"),48;break;case 28:return this.popState(),this.pushState("CLASS_STYLE"),49;break;case 29:return this.popState(),50;break;case 30:return this.pushState("STYLE"),45;break;case 31:return this.popState(),this.pushState("STYLEDEF_STYLES"),46;break;case 32:return this.popState(),47;break;case 33:return this.pushState("SCALE"),17;break;case 34:return 18;case 35:this.popState();break;case 36:this.pushState("STATE");break;case 37:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),25;break;case 38:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),26;break;case 39:return this.popState(),n.yytext=n.yytext.slice(0,-10).trim(),27;break;case 40:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),25;break;case 41:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),26;break;case 42:return this.popState(),n.yytext=n.yytext.slice(0,-10).trim(),27;break;case 43:return 51;case 44:return 52;case 45:return 53;case 46:return 54;case 47:this.pushState("STATE_STRING");break;case 48:return this.pushState("STATE_ID"),"AS";break;case 49:if(!i())return;return this.popState(),"ID";break;case 50:this.popState();break;case 51:return"STATE_DESCR";case 52:throw Error('Error: State name must be a single word. Found: "'+n.yytext.trim()+'"');case 53:return 19;case 54:this.popState();break;case 55:return this.popState(),this.pushState("struct"),20;break;case 56:return this.popState(),21;break;case 57:break;case 58:return this.begin("NOTE"),29;break;case 59:return this.popState(),this.pushState("NOTE_ID"),59;break;case 60:return this.popState(),this.pushState("NOTE_ID"),60;break;case 61:this.popState(),this.pushState("FLOATING_NOTE");break;case 62:return this.popState(),this.pushState("FLOATING_NOTE_ID"),"AS";break;case 63:break;case 64:return"NOTE_TEXT";case 65:if(!i())return;return this.popState(),"ID";break;case 66:if(!i())return;return this.popState(),this.pushState("NOTE_TEXT"),24;break;case 67:return this.popState(),n.yytext=n.yytext.substr(2).trim(),31;break;case 68:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),31;break;case 69:return 6;case 70:return 6;case 71:return 16;case 72:return 57;case 73:if(!i())return;return 24;case 74:return n.yytext=n.yytext.trim(),14;break;case 75:return 15;case 76:return 28;case 77:return 58;case 78:return 5;case 79:return"INVALID"}},"anonymous"),rules:[/^(?:click\b)/i,/^(?:href\b)/i,/^(?:"[^"]*")/i,/^(?:default\b)/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:((?!\n)\s)+)/i,/^(?:#[^\n]*)/i,/^(?:%%(?!\{)[^\n]*)/i,/^(?:scale\s+)/i,/^(?:\d+)/i,/^(?:\s+width\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:classDef\s+)/i,/^(?:DEFAULT\s+)/i,/^(?:\w+\s+)/i,/^(?:[^\n]*)/i,/^(?:class\s+)/i,/^(?:(\w+)+((,\s*\w+)*))/i,/^(?:[^\n]*)/i,/^(?:style\s+)/i,/^(?:[\w,]+\s+)/i,/^(?:[^\n]*)/i,/^(?:scale\s+)/i,/^(?:\d+)/i,/^(?:\s+width\b)/i,/^(?:state\s+)/i,/^(?:.*<<fork>>)/i,/^(?:.*<<join>>)/i,/^(?:.*<<choice>>)/i,/^(?:.*\[\[fork\]\])/i,/^(?:.*\[\[join\]\])/i,/^(?:.*\[\[choice\]\])/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:["])/i,/^(?:\s*as\s+)/i,/^(?:[^\n\{]*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:\w+\s+\w+.*?\{)/i,/^(?:[^\n\s\{]+)/i,/^(?:\n)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:[\n])/i,/^(?:note\s+)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:")/i,/^(?:\s*as\s*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[^\n]*)/i,/^(?:\s*[^:\n\s\-]+)/i,/^(?:\s*:[^:\n;]+)/i,/^(?:[\s\S]*?\n\s*end note\b)/i,/^(?:stateDiagram\s+)/i,/^(?:stateDiagram-v2\s+)/i,/^(?:hide empty description\b)/i,/^(?:\[\*\])/i,/^(?:[^:\n\s\-\{]+)/i,/^(?:\s*:(?:[^:\n;]|:[^:\n;])+)/i,/^(?:-->)/i,/^(?:--)/i,/^(?::::)/i,/^(?:$)/i,/^(?:.)/i],conditions:{LINE:{rules:[10,11,12],inclusive:!1},struct:{rules:[10,11,12,23,27,30,36,43,44,45,46,56,57,58,72,73,74,75,76,77],inclusive:!1},FLOATING_NOTE_ID:{rules:[65],inclusive:!1},FLOATING_NOTE:{rules:[62,63,64],inclusive:!1},NOTE_TEXT:{rules:[67,68],inclusive:!1},NOTE_ID:{rules:[66],inclusive:!1},NOTE:{rules:[59,60,61],inclusive:!1},STYLEDEF_STYLEOPTS:{rules:[],inclusive:!1},STYLEDEF_STYLES:{rules:[32],inclusive:!1},STYLE_IDS:{rules:[],inclusive:!1},STYLE:{rules:[31],inclusive:!1},CLASS_STYLE:{rules:[29],inclusive:!1},CLASS:{rules:[28],inclusive:!1},CLASSDEFID:{rules:[26],inclusive:!1},CLASSDEF:{rules:[24,25],inclusive:!1},acc_descr_multiline:{rules:[21,22],inclusive:!1},acc_descr:{rules:[19],inclusive:!1},acc_title:{rules:[17],inclusive:!1},SCALE:{rules:[14,15,34,35],inclusive:!1},ALIAS:{rules:[],inclusive:!1},STATE_ID:{rules:[49],inclusive:!1},STATE_STRING:{rules:[50,51],inclusive:!1},FORK_STATE:{rules:[],inclusive:!1},STATE:{rules:[10,11,12,37,38,39,40,41,42,47,48,52,53,54,55],inclusive:!1},ID:{rules:[10,11,12],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,11,12,13,16,18,20,23,27,30,33,36,55,58,69,70,71,72,73,74,75,77,78,79],inclusive:!0}}};return Q}();Lt.lexer=me;function Tt(){this.yy={}}return t(Tt,"Parser"),Tt.prototype=Lt,Lt.Parser=Tt,new Tt}();Bt.parser=Bt;var Ee=Bt,_e="TB",qt="TB",Ut="dir",ot="state",nt="root",Gt="relation",ve="classDef",De="style",Ce="applyClass",ut="default",Qt="divider",Zt="fill:none",te="fill: #333",ee="c",re="markdown",ie="normal",$t="rect",Pt="rectWithTitle",Ae="stateStart",xe="stateEnd",Yt="divider",Ht="roundedWithTitle",Le="note",we="noteGroup",ft="statediagram",Ie="state",Ne=`${ft}-${Ie}`,ae="transition",Oe="note",$e="note-edge",Fe=`${ae} ${$e}`,Pe=`${ft}-${Oe}`,Be="cluster",Ge=`${ft}-${Be}`,Ye="cluster-alt",Ve=`${ft}-${Ye}`,ne="parent",oe="note",Me="state",Vt="----",We=`${Vt}${oe}`,zt=`${Vt}${ne}`,At=new Map,Z=0,ce=0,ct=new Map,je=t((e,s,c,r)=>{if(e===Yt&&c?.id!==void 0&&ct.has(c.id)){let m=ct.get(c.id);return ct.set(s,m),m}let u=ce++,f=r?void 0:u;return ct.set(s,f),f},"colorSlotFor");function xt(e="",s=0,c="",r=Vt){let u=c!==null&&c.length>0?`${r}${c}`:"";return`${Me}-${e}${u}-${s}`}t(xt,"stateDomId");var Ue=t((e,s,c,r,u,f,m,k)=>{a.trace("items",s),s.forEach((o)=>{switch(o.stmt){case ot:dt(e,o,c,r,u,f,m,k);break;case ut:dt(e,o,c,r,u,f,m,k);break;case Gt:{dt(e,o.state1,c,r,u,f,m,k),dt(e,o.state2,c,r,u,f,m,k);let D=m==="neo",x={id:"edge"+Z,start:o.state1.id,end:o.state2.id,arrowhead:"normal",arrowTypeEnd:D?"arrow_barb_neo":"arrow_barb",style:Zt,labelStyle:"",label:b.sanitizeText(o.description??"",l()),arrowheadStyle:te,labelpos:ee,labelType:re,thickness:ie,classes:ae,look:m};u.push(x),Z++}break}})},"setupDoc"),Kt=t((e,s=qt)=>{let c=s;if(e.doc){for(let r of e.doc)if(r.stmt==="dir")c=r.value}return c},"getDir");function ht(e,s,c){if(!s.id||s.id==="</join></fork>"||s.id==="</choice>")return;if(s.cssClasses){if(!Array.isArray(s.cssCompiledStyles))s.cssCompiledStyles=[];s.cssClasses.split(" ").forEach((u)=>{let f=c.get(u);if(f)s.cssCompiledStyles=[...s.cssCompiledStyles??[],...f.styles]})}let r=e.find((u)=>u.id===s.id);if(r)Object.assign(r,s);else e.push(s)}t(ht,"insertOrUpdateNode");function de(e){return e?.classes?.join(" ")??""}t(de,"getClassesFromDbInfo");function fe(e){return e?.styles??[]}t(fe,"getStylesFromDbInfo");var dt=t((e,s,c,r,u,f,m,k)=>{let o=s.id,D=c.get(o),x=de(D),Y=fe(D),V=l(),j=x.trim()!==""||Y.length>0;if(a.info("dataFetcher parsedItem",s,D,Y),o!=="root"){let F=$t;if(s.start===!0)F=Ae;else if(s.start===!1)F=xe;if(s.type!==ut)F=s.type;if(!At.get(o))At.set(o,{id:o,shape:F,description:b.sanitizeText(o,V),cssClasses:`${x} ${Ne}`,cssStyles:Y});let y=At.get(o);if(s.description){if(Array.isArray(y.description))y.shape=Pt,y.description.push(s.description);else if(y.description?.length&&y.description.length>0)if(y.shape=Pt,y.description===o)y.description=[s.description];else y.description=[y.description,s.description];else y.shape=$t,y.description=s.description;y.description=b.sanitizeTextOrArray(y.description,V)}if(y.description?.length===1&&y.shape===Pt)if(y.type==="group")y.shape=Ht;else y.shape=$t;if(!y.type&&s.doc)a.info("Setting cluster for XCX",o,Kt(s)),y.type="group",y.isGroup=!0,y.dir=Kt(s),y.shape=s.type===Qt?Yt:Ht,y.colorIndex=je(y.shape,o,e,j),y.cssClasses=`${y.cssClasses} ${Ge} ${f?Ve:""}`;let M={labelStyle:"",shape:y.shape,label:y.description,cssClasses:y.cssClasses,cssCompiledStyles:[],cssStyles:y.cssStyles,id:o,dir:y.dir,domId:xt(o,Z),type:y.type,isGroup:y.type==="group",colorIndex:y.colorIndex,padding:8,rx:10,ry:10,look:m,labelType:"markdown"};if(M.shape===Yt)M.label="";if(e&&e.id!=="root")a.trace("Setting node ",o," to be child of its parent ",e.id),M.parentId=e.id;if(M.centerLabel=!0,s.note){let P={labelStyle:"",shape:Le,label:s.note.text,labelType:"markdown",cssClasses:Pe,cssStyles:[],cssCompiledStyles:[],id:o+We+"-"+Z,domId:xt(o,Z,oe),type:"node",isGroup:!1,padding:V.flowchart?.padding,look:m,position:s.note.position},z=o+zt,W={labelStyle:"",shape:we,label:s.note.text,cssClasses:y.cssClasses,cssStyles:[],id:o+zt,domId:xt(o,Z,ne),type:"group",isGroup:!0,padding:16,look:m,position:s.note.position};Z++,W.id=z,P.parentId=z,ht(r,W,k),ht(r,P,k),ht(r,M,k);let K=o,O=P.id;if(s.note.position==="left of")K=P.id,O=o;u.push({id:K+"-"+O,start:K,end:O,arrowhead:"none",arrowTypeEnd:"",style:Zt,labelStyle:"",classes:Fe,pattern:"dashed",arrowheadStyle:te,labelpos:ee,labelType:re,thickness:ie,look:m})}else ht(r,M,k)}if(s.doc)a.trace("Adding nodes children "),Ue(s,s.doc,c,r,u,!f,m,k)},"dataFetcher"),He=t(()=>{At.clear(),Z=0,ce=0,ct.clear()},"reset"),Se=t((e,s=qt)=>{if(!e.doc)return s;let c=s;for(let r of e.doc)if(r.stmt==="dir")c=r.value;return c},"getDir"),ze=t(function(e,s){return s.db.getClasses()},"getClasses"),Ke=t(async function(e,s,c,r){a.info("REF0:"),a.info("Drawing state diagram (v2)",s);let{securityLevel:u,state:f,layout:m}=l();r.db.extract(r.db.getRootDocV2());let k=r.db.getData(),o=he(s,u);if(k.type=r.type,k.layoutAlgorithm=ye(m),k.nodeSpacing=f?.nodeSpacing||50,k.rankSpacing=f?.rankSpacing||50,l().look==="neo")k.markers=["barbNeo"];else k.markers=["barb"];k.diagramId=s,await ge(k,o);let x=8;try{(typeof r.db.getLinks==="function"?r.db.getLinks():new Map).forEach((V,j)=>{let F=typeof j==="string"?j:typeof j?.id==="string"?j.id:"",y=k.nodes.find((O)=>O.id===F);if(!F){a.warn("⚠️ Invalid or missing stateId from key:",JSON.stringify(j));return}let M=o.node()?.querySelectorAll("g.node, g.rough-node"),P;if(M?.forEach((O)=>{let st=O.textContent?.trim();if(O.id===y?.domId||st===F)P=O}),!P){a.warn("⚠️ Could not find node matching text:",F);return}let z=P.parentNode;if(!z){a.warn("⚠️ Node has no parent, cannot wrap:",F);return}let W=document.createElementNS("http://www.w3.org/2000/svg","a"),K=V.url.replace(/^"+|"+$/g,"");if(W.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",K),W.setAttribute("target","_blank"),V.tooltip){let O=V.tooltip.replace(/^"+|"+$/g,"");W.setAttribute("title",O),P.setAttribute("title",O)}z.replaceChild(W,P),W.appendChild(P),a.info("\uD83D\uDD17 Wrapped node in <a> tag for:",F,V.url)})}catch(Y){a.error("❌ Error injecting clickable links:",Y)}N.insertTitle(o,"statediagramTitleText",f?.titleTopMargin??25,r.db.getDiagramTitle()),ue(o,x,ft,f?.useMaxWidth??!0)},"draw"),Xe={getClasses:ze,draw:Ke,getDir:Se},G={START_NODE:"[*]",START_TYPE:"start",END_NODE:"[*]",END_TYPE:"end",COLOR_KEYWORD:"color",FILL_KEYWORD:"fill",BG_FILL:"bgFill",STYLECLASS_SEP:","},Xt=t(()=>new Map,"newClassesList"),Jt=t(()=>({relations:[],states:new Map,documents:{}}),"newDoc"),Ct=t((e)=>JSON.parse(JSON.stringify(e)),"clone"),Je=class{constructor(e){this.version=e,this.nodes=[],this.edges=[],this.rootDoc=[],this.classes=Xt(),this.documents={root:Jt()},this.currentDocument=this.documents.root,this.startEndCount=0,this.dividerCnt=0,this.links=new Map,this.funs=[],this.getAccTitle=E,this.setAccTitle=S,this.getAccDescription=A,this.setAccDescription=T,this.setDiagramTitle=L,this.getDiagramTitle=R,this.clear(),this.setRootDoc=this.setRootDoc.bind(this),this.getDividerId=this.getDividerId.bind(this),this.setDirection=this.setDirection.bind(this),this.trimColon=this.trimColon.bind(this),this.bindFunctions=this.bindFunctions.bind(this)}static{t(this,"StateDB")}static{this.relationType={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3}}extract(e){this.clear(!0);for(let r of Array.isArray(e)?e:e.doc)switch(r.stmt){case ot:this.addState(r.id.trim(),r.type,r.doc,r.description,r.note);break;case Gt:this.addRelation(r.state1,r.state2,r.description);break;case ve:this.addStyleClass(r.id.trim(),r.classes);break;case De:this.handleStyleDef(r);break;case Ce:this.setCssClass(r.id.trim(),r.styleClass);break;case"click":this.addLink(r.id,r.url,r.tooltip);break}let s=this.getStates(),c=l();He(),dt(void 0,this.getRootDocV2(),s,this.nodes,this.edges,!0,c.look,this.classes);for(let r of this.nodes){if(!Array.isArray(r.label))continue;if(r.description=r.label.slice(1),r.isGroup&&r.description.length>0)throw Error(`Group nodes can only have label. Remove the additional description for node [${r.id}]`);r.label=r.label[0]}}handleStyleDef(e){let s=e.id.trim().split(","),c=e.styleClass.split(",");for(let r of s){let u=this.getState(r);if(!u){let f=r.trim();this.addState(f),u=this.getState(f)}if(u)u.styles=c.map((f)=>f.replace(/;/g,"")?.trim())}}setRootDoc(e){if(a.info("Setting root doc",e),this.rootDoc=e,this.version===1)this.extract(e);else this.extract(this.getRootDocV2())}docTranslator(e,s,c){if(s.stmt===Gt){this.docTranslator(e,s.state1,!0),this.docTranslator(e,s.state2,!1);return}if(s.stmt===ot)if(s.id===G.START_NODE)s.id=e.id+(c?"_start":"_end"),s.start=c;else s.id=s.id.trim();if(s.stmt!==nt&&s.stmt!==ot||!s.doc)return;let r=[],u=[];for(let f of s.doc)if(f.type===Qt){let m=Ct(f);m.doc=Ct(u),r.push(m),u=[]}else u.push(f);if(r.length>0&&u.length>0){let f={stmt:ot,id:Gi(),type:"divider",doc:Ct(u)};r.push(Ct(f)),s.doc=r}s.doc.forEach((f)=>this.docTranslator(s,f,!0))}getRootDocV2(){return this.docTranslator({id:nt,stmt:nt},{id:nt,stmt:nt,doc:this.rootDoc},!0),{id:nt,doc:this.rootDoc}}addState(e,s=ut,c=void 0,r=void 0,u=void 0,f=void 0,m=void 0,k=void 0){let o=e?.trim();if(!this.currentDocument.states.has(o))a.info("Adding state ",o,r),this.currentDocument.states.set(o,{stmt:ot,id:o,descriptions:[],type:s,doc:c,note:u,classes:[],styles:[],textStyles:[]});else{let D=this.currentDocument.states.get(o);if(!D)throw Error(`State not found: ${o}`);if(!D.doc)D.doc=c;if(!D.type)D.type=s}if(r)a.info("Setting state description",o,r),(Array.isArray(r)?r:[r]).forEach((x)=>this.addDescription(o,x.trim()));if(u){let D=this.currentDocument.states.get(o);if(!D)throw Error(`State not found: ${o}`);D.note=u,D.note.text=b.sanitizeText(D.note.text,l())}if(f)a.info("Setting state classes",o,f),(Array.isArray(f)?f:[f]).forEach((x)=>this.setCssClass(o,x.trim()));if(m)a.info("Setting state styles",o,m),(Array.isArray(m)?m:[m]).forEach((x)=>this.setStyle(o,x.trim()));if(k)a.info("Setting state styles",o,m),(Array.isArray(k)?k:[k]).forEach((x)=>this.setTextStyle(o,x.trim()))}clear(e){if(this.nodes=[],this.edges=[],this.funs=[this.setupToolTips.bind(this)],this.documents={root:Jt()},this.currentDocument=this.documents.root,this.startEndCount=0,this.classes=Xt(),!e)this.links=new Map,C()}getState(e){return this.currentDocument.states.get(e)}getStates(){return this.currentDocument.states}logDocuments(){a.info("Documents = ",this.documents)}getRelations(){return this.currentDocument.relations}addLink(e,s,c){this.links.set(e,{url:s,tooltip:c}),a.warn("Adding link",e,s,c)}getLinks(){return this.links}startIdIfNeeded(e=""){if(e===G.START_NODE)return this.startEndCount++,`${G.START_TYPE}${this.startEndCount}`;return e}startTypeIfNeeded(e="",s=ut){return e===G.START_NODE?G.START_TYPE:s}endIdIfNeeded(e=""){if(e===G.END_NODE)return this.startEndCount++,`${G.END_TYPE}${this.startEndCount}`;return e}endTypeIfNeeded(e="",s=ut){return e===G.END_NODE?G.END_TYPE:s}addRelationObjs(e,s,c=""){let r=this.startIdIfNeeded(e.id.trim()),u=this.startTypeIfNeeded(e.id.trim(),e.type),f=this.startIdIfNeeded(s.id.trim()),m=this.startTypeIfNeeded(s.id.trim(),s.type);this.addState(r,u,e.doc,e.description,e.note,e.classes,e.styles,e.textStyles),this.addState(f,m,s.doc,s.description,s.note,s.classes,s.styles,s.textStyles),this.currentDocument.relations.push({id1:r,id2:f,relationTitle:b.sanitizeText(c,l())})}addRelation(e,s,c){if(typeof e==="object"&&typeof s==="object")this.addRelationObjs(e,s,c);else if(typeof e==="string"&&typeof s==="string"){let r=this.startIdIfNeeded(e.trim()),u=this.startTypeIfNeeded(e),f=this.endIdIfNeeded(s.trim()),m=this.endTypeIfNeeded(s);this.addState(r,u),this.addState(f,m),this.currentDocument.relations.push({id1:r,id2:f,relationTitle:c?b.sanitizeText(c,l()):void 0})}}addDescription(e,s){let c=this.currentDocument.states.get(e),r=s.startsWith(":")?s.replace(":","").trim():s;c?.descriptions?.push(b.sanitizeText(r,l()))}cleanupLabel(e){return e.startsWith(":")?e.slice(2).trim():e.trim()}getDividerId(){return this.dividerCnt++,`divider-id-${this.dividerCnt}`}addStyleClass(e,s=""){if(!this.classes.has(e))this.classes.set(e,{id:e,styles:[],textStyles:[]});let c=this.classes.get(e);if(s&&c)s.split(G.STYLECLASS_SEP).forEach((r)=>{let u=r.replace(/([^;]*);/,"$1").trim();if(RegExp(G.COLOR_KEYWORD).exec(r)){let m=u.replace(G.FILL_KEYWORD,G.BG_FILL).replace(G.COLOR_KEYWORD,G.FILL_KEYWORD);c.textStyles.push(m)}c.styles.push(u)})}getClasses(){return this.classes}setupToolTips(e){let s=Ft();p(e).select("svg").selectAll("g.node, g.rough-node").on("mouseover",(u)=>{let f=p(u.currentTarget),m=f.attr("title");if(m===null)return;let k=u.currentTarget?.getBoundingClientRect();s.transition().duration(200).style("opacity",".9"),s.style("left",window.scrollX+k.left+(k.right-k.left)/2+"px").style("top",window.scrollY+k.bottom+"px"),s.html(Re.sanitize(m)),f.classed("hover",!0)}).on("mouseout",(u)=>{s.transition().duration(500).style("opacity",0),p(u.currentTarget).classed("hover",!1)})}setCssClass(e,s){e.split(",").forEach((c)=>{let r=this.getState(c);if(!r){let u=c.trim();this.addState(u),r=this.getState(u)}r?.classes?.push(s)})}setStyle(e,s){this.getState(e)?.styles?.push(s)}setTextStyle(e,s){this.getState(e)?.textStyles?.push(s)}bindFunctions(e){this.funs.forEach((s)=>{s(e)})}getDirectionStatement(){return this.rootDoc.find((e)=>e.stmt===Ut)}getDirection(){return this.getDirectionStatement()?.value??_e}setDirection(e){let s=this.getDirectionStatement();if(s)s.value=e;else this.rootDoc.unshift({stmt:Ut,value:e})}trimColon(e){return e.startsWith(":")?e.slice(1).trim():e.trim()}getData(){let e=l();for(let s of this.nodes)if(s.wrappingWidth??=e.state?.wrappingWidth,!s.isGroup)s.minWidth??=e.state?.minNodeWidth;return{nodes:this.nodes,edges:this.edges,other:{},config:e,direction:Se(this.getRootDocV2())}}getConfig(){return l().state}},qe=t((e)=>{let{theme:s,bkgColorArray:c,borderColorArray:r}=e;if(!se(s,r))return"";let u=le(e.look),f=pe(c),m="";for(let k=0;k<yt(r);k++){let o=r[k],D=f?`fill: ${c[k%c.length]};`:"",x=`[data-look="${u}"][data-color-id="color-${k}"]`;m+=`
|
|
6
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:t(function(){var g=this.next();if(g)return g;else return this.lex()},"lex"),begin:t(function(g){this.conditionStack.push(g)},"begin"),popState:t(function(){var g=this.conditionStack.length-1;if(g>0)return this.conditionStack.pop();else return this.conditionStack[0]},"popState"),_currentRules:t(function(){if(this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1])return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;else return this.conditions.INITIAL.rules},"_currentRules"),topState:t(function(g){if(g=this.conditionStack.length-1-Math.abs(g||0),g>=0)return this.conditionStack[g];else return"INITIAL"},"topState"),pushState:t(function(g){this.begin(g)},"pushState"),stateStackSize:t(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:t(function(g,n,v,w){function i(){let d=n.yytext.indexOf("%%");if(d===0)return!1;if(d>0){let X=n.yytext.slice(0,d),J=n.yytext.slice(d);if(J)g.lexer.unput(J);n.yytext=X}return!0}t(i,"processId");var it=w;switch(v){case 0:return 38;case 1:return 40;case 2:return 39;case 3:return 44;case 4:return 51;case 5:return 52;case 6:return 53;case 7:return 54;case 8:return 5;case 9:break;case 10:break;case 11:break;case 12:break;case 13:return this.pushState("SCALE"),17;break;case 14:return 18;case 15:this.popState();break;case 16:return this.begin("acc_title"),33;break;case 17:return this.popState(),"acc_title_value";break;case 18:return this.begin("acc_descr"),35;break;case 19:return this.popState(),"acc_descr_value";break;case 20:this.begin("acc_descr_multiline");break;case 21:this.popState();break;case 22:return"acc_descr_multiline_value";case 23:return this.pushState("CLASSDEF"),41;break;case 24:return this.popState(),this.pushState("CLASSDEFID"),"DEFAULT_CLASSDEF_ID";break;case 25:return this.popState(),this.pushState("CLASSDEFID"),42;break;case 26:return this.popState(),43;break;case 27:return this.pushState("CLASS"),48;break;case 28:return this.popState(),this.pushState("CLASS_STYLE"),49;break;case 29:return this.popState(),50;break;case 30:return this.pushState("STYLE"),45;break;case 31:return this.popState(),this.pushState("STYLEDEF_STYLES"),46;break;case 32:return this.popState(),47;break;case 33:return this.pushState("SCALE"),17;break;case 34:return 18;case 35:this.popState();break;case 36:this.pushState("STATE");break;case 37:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),25;break;case 38:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),26;break;case 39:return this.popState(),n.yytext=n.yytext.slice(0,-10).trim(),27;break;case 40:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),25;break;case 41:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),26;break;case 42:return this.popState(),n.yytext=n.yytext.slice(0,-10).trim(),27;break;case 43:return 51;case 44:return 52;case 45:return 53;case 46:return 54;case 47:this.pushState("STATE_STRING");break;case 48:return this.pushState("STATE_ID"),"AS";break;case 49:if(!i())return;return this.popState(),"ID";break;case 50:this.popState();break;case 51:return"STATE_DESCR";case 52:throw Error('Error: State name must be a single word. Found: "'+n.yytext.trim()+'"');case 53:return 19;case 54:this.popState();break;case 55:return this.popState(),this.pushState("struct"),20;break;case 56:return this.popState(),21;break;case 57:break;case 58:return this.begin("NOTE"),29;break;case 59:return this.popState(),this.pushState("NOTE_ID"),59;break;case 60:return this.popState(),this.pushState("NOTE_ID"),60;break;case 61:this.popState(),this.pushState("FLOATING_NOTE");break;case 62:return this.popState(),this.pushState("FLOATING_NOTE_ID"),"AS";break;case 63:break;case 64:return"NOTE_TEXT";case 65:if(!i())return;return this.popState(),"ID";break;case 66:if(!i())return;return this.popState(),this.pushState("NOTE_TEXT"),24;break;case 67:return this.popState(),n.yytext=n.yytext.substr(2).trim(),31;break;case 68:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),31;break;case 69:return 6;case 70:return 6;case 71:return 16;case 72:return 57;case 73:if(!i())return;return 24;case 74:return n.yytext=n.yytext.trim(),14;break;case 75:return 15;case 76:return 28;case 77:return 58;case 78:return 5;case 79:return"INVALID"}},"anonymous"),rules:[/^(?:click\b)/i,/^(?:href\b)/i,/^(?:"[^"]*")/i,/^(?:default\b)/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:((?!\n)\s)+)/i,/^(?:#[^\n]*)/i,/^(?:%%(?!\{)[^\n]*)/i,/^(?:scale\s+)/i,/^(?:\d+)/i,/^(?:\s+width\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:classDef\s+)/i,/^(?:DEFAULT\s+)/i,/^(?:\w+\s+)/i,/^(?:[^\n]*)/i,/^(?:class\s+)/i,/^(?:(\w+)+((,\s*\w+)*))/i,/^(?:[^\n]*)/i,/^(?:style\s+)/i,/^(?:[\w,]+\s+)/i,/^(?:[^\n]*)/i,/^(?:scale\s+)/i,/^(?:\d+)/i,/^(?:\s+width\b)/i,/^(?:state\s+)/i,/^(?:.*<<fork>>)/i,/^(?:.*<<join>>)/i,/^(?:.*<<choice>>)/i,/^(?:.*\[\[fork\]\])/i,/^(?:.*\[\[join\]\])/i,/^(?:.*\[\[choice\]\])/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:["])/i,/^(?:\s*as\s+)/i,/^(?:[^\n\{]*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:\w+\s+\w+.*?\{)/i,/^(?:[^\n\s\{]+)/i,/^(?:\n)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:[\n])/i,/^(?:note\s+)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:")/i,/^(?:\s*as\s*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[^\n]*)/i,/^(?:\s*[^:\n\s\-]+)/i,/^(?:\s*:[^:\n;]+)/i,/^(?:[\s\S]*?\n\s*end note\b)/i,/^(?:stateDiagram\s+)/i,/^(?:stateDiagram-v2\s+)/i,/^(?:hide empty description\b)/i,/^(?:\[\*\])/i,/^(?:[^:\n\s\-\{]+)/i,/^(?:\s*:(?:[^:\n;]|:[^:\n;])+)/i,/^(?:-->)/i,/^(?:--)/i,/^(?::::)/i,/^(?:$)/i,/^(?:.)/i],conditions:{LINE:{rules:[10,11,12],inclusive:!1},struct:{rules:[10,11,12,23,27,30,36,43,44,45,46,56,57,58,72,73,74,75,76,77],inclusive:!1},FLOATING_NOTE_ID:{rules:[65],inclusive:!1},FLOATING_NOTE:{rules:[62,63,64],inclusive:!1},NOTE_TEXT:{rules:[67,68],inclusive:!1},NOTE_ID:{rules:[66],inclusive:!1},NOTE:{rules:[59,60,61],inclusive:!1},STYLEDEF_STYLEOPTS:{rules:[],inclusive:!1},STYLEDEF_STYLES:{rules:[32],inclusive:!1},STYLE_IDS:{rules:[],inclusive:!1},STYLE:{rules:[31],inclusive:!1},CLASS_STYLE:{rules:[29],inclusive:!1},CLASS:{rules:[28],inclusive:!1},CLASSDEFID:{rules:[26],inclusive:!1},CLASSDEF:{rules:[24,25],inclusive:!1},acc_descr_multiline:{rules:[21,22],inclusive:!1},acc_descr:{rules:[19],inclusive:!1},acc_title:{rules:[17],inclusive:!1},SCALE:{rules:[14,15,34,35],inclusive:!1},ALIAS:{rules:[],inclusive:!1},STATE_ID:{rules:[49],inclusive:!1},STATE_STRING:{rules:[50,51],inclusive:!1},FORK_STATE:{rules:[],inclusive:!1},STATE:{rules:[10,11,12,37,38,39,40,41,42,47,48,52,53,54,55],inclusive:!1},ID:{rules:[10,11,12],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,11,12,13,16,18,20,23,27,30,33,36,55,58,69,70,71,72,73,74,75,77,78,79],inclusive:!0}}};return Q}();Lt.lexer=me;function Tt(){this.yy={}}return t(Tt,"Parser"),Tt.prototype=Lt,Lt.Parser=Tt,new Tt}();Bt.parser=Bt;var Ee=Bt,_e="TB",qt="TB",Ut="dir",ot="state",nt="root",Gt="relation",ve="classDef",De="style",Ce="applyClass",ut="default",Qt="divider",Zt="fill:none",te="fill: #333",ee="c",se="markdown",re="normal",$t="rect",Pt="rectWithTitle",Ae="stateStart",xe="stateEnd",Yt="divider",Ht="roundedWithTitle",Le="note",we="noteGroup",ft="statediagram",Ie="state",Ne=`${ft}-${Ie}`,ie="transition",Oe="note",$e="note-edge",Fe=`${ie} ${$e}`,Pe=`${ft}-${Oe}`,Be="cluster",Ge=`${ft}-${Be}`,Ye="cluster-alt",Ve=`${ft}-${Ye}`,ae="parent",ne="note",Me="state",Vt="----",We=`${Vt}${ne}`,zt=`${Vt}${ae}`,At=new Map,Z=0,oe=0,ct=new Map,je=t((e,s,c,r)=>{if(e===Yt&&c?.id!==void 0&&ct.has(c.id)){let m=ct.get(c.id);return ct.set(s,m),m}let u=oe++,f=r?void 0:u;return ct.set(s,f),f},"colorSlotFor");function xt(e="",s=0,c="",r=Vt){let u=c!==null&&c.length>0?`${r}${c}`:"";return`${Me}-${e}${u}-${s}`}t(xt,"stateDomId");var Ue=t((e,s,c,r,u,f,m,k)=>{a.trace("items",s),s.forEach((o)=>{switch(o.stmt){case ot:dt(e,o,c,r,u,f,m,k);break;case ut:dt(e,o,c,r,u,f,m,k);break;case Gt:{dt(e,o.state1,c,r,u,f,m,k),dt(e,o.state2,c,r,u,f,m,k);let D=m==="neo",x={id:"edge"+Z,start:o.state1.id,end:o.state2.id,arrowhead:"normal",arrowTypeEnd:D?"arrow_barb_neo":"arrow_barb",style:Zt,labelStyle:"",label:b.sanitizeText(o.description??"",l()),arrowheadStyle:te,labelpos:ee,labelType:se,thickness:re,classes:ie,look:m};u.push(x),Z++}break}})},"setupDoc"),Kt=t((e,s=qt)=>{let c=s;if(e.doc){for(let r of e.doc)if(r.stmt==="dir")c=r.value}return c},"getDir");function ht(e,s,c){if(!s.id||s.id==="</join></fork>"||s.id==="</choice>")return;if(s.cssClasses){if(!Array.isArray(s.cssCompiledStyles))s.cssCompiledStyles=[];s.cssClasses.split(" ").forEach((u)=>{let f=c.get(u);if(f)s.cssCompiledStyles=[...s.cssCompiledStyles??[],...f.styles]})}let r=e.find((u)=>u.id===s.id);if(r)Object.assign(r,s);else e.push(s)}t(ht,"insertOrUpdateNode");function de(e){return e?.classes?.join(" ")??""}t(de,"getClassesFromDbInfo");function fe(e){return e?.styles??[]}t(fe,"getStylesFromDbInfo");var dt=t((e,s,c,r,u,f,m,k)=>{let o=s.id,D=c.get(o),x=de(D),G=fe(D),Y=l(),j=x.trim()!==""||G.length>0;if(a.info("dataFetcher parsedItem",s,D,G),o!=="root"){let O=$t;if(s.start===!0)O=Ae;else if(s.start===!1)O=xe;if(s.type!==ut)O=s.type;if(!At.get(o))At.set(o,{id:o,shape:O,description:b.sanitizeText(o,Y),cssClasses:`${x} ${Ne}`,cssStyles:G});let y=At.get(o);if(s.description){if(Array.isArray(y.description))y.shape=Pt,y.description.push(s.description);else if(y.description?.length&&y.description.length>0)if(y.shape=Pt,y.description===o)y.description=[s.description];else y.description=[y.description,s.description];else y.shape=$t,y.description=s.description;y.description=b.sanitizeTextOrArray(y.description,Y)}if(y.description?.length===1&&y.shape===Pt)if(y.type==="group")y.shape=Ht;else y.shape=$t;if(!y.type&&s.doc)a.info("Setting cluster for XCX",o,Kt(s)),y.type="group",y.isGroup=!0,y.dir=Kt(s),y.shape=s.type===Qt?Yt:Ht,y.colorIndex=je(y.shape,o,e,j),y.cssClasses=`${y.cssClasses} ${Ge} ${f?Ve:""}`;let V={labelStyle:"",shape:y.shape,label:y.description,cssClasses:y.cssClasses,cssCompiledStyles:[],cssStyles:y.cssStyles,id:o,dir:y.dir,domId:xt(o,Z),type:y.type,isGroup:y.type==="group",colorIndex:y.colorIndex,padding:8,rx:10,ry:10,look:m,labelType:"markdown"};if(V.shape===Yt)V.label="";if(e&&e.id!=="root")a.trace("Setting node ",o," to be child of its parent ",e.id),V.parentId=e.id;if(V.centerLabel=!0,s.note){let F={labelStyle:"",shape:Le,label:s.note.text,labelType:"markdown",cssClasses:Pe,cssStyles:[],cssCompiledStyles:[],id:o+We+"-"+Z,domId:xt(o,Z,ne),type:"node",isGroup:!1,padding:Y.flowchart?.padding,look:m,position:s.note.position},z=o+zt,W={labelStyle:"",shape:we,label:s.note.text,cssClasses:y.cssClasses,cssStyles:[],id:o+zt,domId:xt(o,Z,ae),type:"group",isGroup:!0,padding:16,look:m,position:s.note.position};Z++,W.id=z,F.parentId=z,ht(r,W,k),ht(r,F,k),ht(r,V,k);let K=o,N=F.id;if(s.note.position==="left of")K=F.id,N=o;u.push({id:K+"-"+N,start:K,end:N,arrowhead:"none",arrowTypeEnd:"",style:Zt,labelStyle:"",classes:Fe,pattern:"dashed",arrowheadStyle:te,labelpos:ee,labelType:se,thickness:re,look:m})}else ht(r,V,k)}if(s.doc)a.trace("Adding nodes children "),Ue(s,s.doc,c,r,u,!f,m,k)},"dataFetcher"),He=t(()=>{At.clear(),Z=0,oe=0,ct.clear()},"reset"),Se=t((e,s=qt)=>{if(!e.doc)return s;let c=s;for(let r of e.doc)if(r.stmt==="dir")c=r.value;return c},"getDir"),ze=t(function(e,s){return s.db.getClasses()},"getClasses"),Ke=t(async function(e,s,c,r){a.info("REF0:"),a.info("Drawing state diagram (v2)",s);let{securityLevel:u,state:f,layout:m}=l();r.db.extract(r.db.getRootDocV2());let k=r.db.getData(),o=he(s,u);if(k.type=r.type,k.layoutAlgorithm=ye(m),k.nodeSpacing=f?.nodeSpacing||50,k.rankSpacing=f?.rankSpacing||50,l().look==="neo")k.markers=["barbNeo"];else k.markers=["barb"];k.diagramId=s,await ge(k,o);let x=8;try{(typeof r.db.getLinks==="function"?r.db.getLinks():new Map).forEach((Y,j)=>{let O=typeof j==="string"?j:typeof j?.id==="string"?j.id:"",y=k.nodes.find((N)=>N.id===O);if(!O){a.warn("⚠️ Invalid or missing stateId from key:",JSON.stringify(j));return}let V=o.node()?.querySelectorAll("g.node, g.rough-node"),F;if(V?.forEach((N)=>{let st=N.textContent?.trim();if(N.id===y?.domId||st===O)F=N}),!F){a.warn("⚠️ Could not find node matching text:",O);return}let z=F.parentNode;if(!z){a.warn("⚠️ Node has no parent, cannot wrap:",O);return}let W=document.createElementNS("http://www.w3.org/2000/svg","a"),K=Y.url.replace(/^"+|"+$/g,"");if(W.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",K),W.setAttribute("target","_blank"),Y.tooltip){let N=Y.tooltip.replace(/^"+|"+$/g,"");W.setAttribute("title",N),F.setAttribute("title",N)}z.replaceChild(W,F),W.appendChild(F),a.info("\uD83D\uDD17 Wrapped node in <a> tag for:",O,Y.url)})}catch(G){a.error("❌ Error injecting clickable links:",G)}M.insertTitle(o,"statediagramTitleText",f?.titleTopMargin??25,r.db.getDiagramTitle()),ue(o,x,ft,f?.useMaxWidth??!0)},"draw"),Xe={getClasses:ze,draw:Ke,getDir:Se},B={START_NODE:"[*]",START_TYPE:"start",END_NODE:"[*]",END_TYPE:"end",COLOR_KEYWORD:"color",FILL_KEYWORD:"fill",BG_FILL:"bgFill",STYLECLASS_SEP:","},Xt=t(()=>new Map,"newClassesList"),Jt=t(()=>({relations:[],states:new Map,documents:{}}),"newDoc"),Ct=t((e)=>JSON.parse(JSON.stringify(e)),"clone"),Je=class{constructor(e){this.version=e,this.nodes=[],this.edges=[],this.rootDoc=[],this.classes=Xt(),this.documents={root:Jt()},this.currentDocument=this.documents.root,this.startEndCount=0,this.dividerCnt=0,this.links=new Map,this.funs=[],this.getAccTitle=E,this.setAccTitle=S,this.getAccDescription=A,this.setAccDescription=T,this.setDiagramTitle=L,this.getDiagramTitle=R,this.clear(),this.setRootDoc=this.setRootDoc.bind(this),this.getDividerId=this.getDividerId.bind(this),this.setDirection=this.setDirection.bind(this),this.trimColon=this.trimColon.bind(this),this.bindFunctions=this.bindFunctions.bind(this)}static{t(this,"StateDB")}static{this.relationType={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3}}extract(e){this.clear(!0);for(let r of Array.isArray(e)?e:e.doc)switch(r.stmt){case ot:this.addState(r.id.trim(),r.type,r.doc,r.description,r.note);break;case Gt:this.addRelation(r.state1,r.state2,r.description);break;case ve:this.addStyleClass(r.id.trim(),r.classes);break;case De:this.handleStyleDef(r);break;case Ce:this.setCssClass(r.id.trim(),r.styleClass);break;case"click":this.addLink(r.id,r.url,r.tooltip);break}let s=this.getStates(),c=l();He(),dt(void 0,this.getRootDocV2(),s,this.nodes,this.edges,!0,c.look,this.classes);for(let r of this.nodes){if(!Array.isArray(r.label))continue;if(r.description=r.label.slice(1),r.isGroup&&r.description.length>0)throw Error(`Group nodes can only have label. Remove the additional description for node [${r.id}]`);r.label=r.label[0]}}handleStyleDef(e){let s=e.id.trim().split(","),c=e.styleClass.split(",");for(let r of s){let u=this.getState(r);if(!u){let f=r.trim();this.addState(f),u=this.getState(f)}if(u)u.styles=c.map((f)=>f.replace(/;/g,"")?.trim())}}setRootDoc(e){if(a.info("Setting root doc",e),this.rootDoc=e,this.version===1)this.extract(e);else this.extract(this.getRootDocV2())}docTranslator(e,s,c){if(s.stmt===Gt){this.docTranslator(e,s.state1,!0),this.docTranslator(e,s.state2,!1);return}if(s.stmt===ot)if(s.id===B.START_NODE)s.id=e.id+(c?"_start":"_end"),s.start=c;else s.id=s.id.trim();if(s.stmt!==nt&&s.stmt!==ot||!s.doc)return;let r=[],u=[];for(let f of s.doc)if(f.type===Qt){let m=Ct(f);m.doc=Ct(u),r.push(m),u=[]}else u.push(f);if(r.length>0&&u.length>0){let f={stmt:ot,id:Yi(),type:"divider",doc:Ct(u)};r.push(Ct(f)),s.doc=r}s.doc.forEach((f)=>this.docTranslator(s,f,!0))}getRootDocV2(){return this.docTranslator({id:nt,stmt:nt},{id:nt,stmt:nt,doc:this.rootDoc},!0),{id:nt,doc:this.rootDoc}}addState(e,s=ut,c=void 0,r=void 0,u=void 0,f=void 0,m=void 0,k=void 0){let o=e?.trim();if(!this.currentDocument.states.has(o))a.info("Adding state ",o,r),this.currentDocument.states.set(o,{stmt:ot,id:o,descriptions:[],type:s,doc:c,note:u,classes:[],styles:[],textStyles:[]});else{let D=this.currentDocument.states.get(o);if(!D)throw Error(`State not found: ${o}`);if(!D.doc)D.doc=c;if(!D.type)D.type=s}if(r)a.info("Setting state description",o,r),(Array.isArray(r)?r:[r]).forEach((x)=>this.addDescription(o,x.trim()));if(u){let D=this.currentDocument.states.get(o);if(!D)throw Error(`State not found: ${o}`);D.note=u,D.note.text=b.sanitizeText(D.note.text,l())}if(f)a.info("Setting state classes",o,f),(Array.isArray(f)?f:[f]).forEach((x)=>this.setCssClass(o,x.trim()));if(m)a.info("Setting state styles",o,m),(Array.isArray(m)?m:[m]).forEach((x)=>this.setStyle(o,x.trim()));if(k)a.info("Setting state styles",o,m),(Array.isArray(k)?k:[k]).forEach((x)=>this.setTextStyle(o,x.trim()))}clear(e){if(this.nodes=[],this.edges=[],this.funs=[this.setupToolTips.bind(this)],this.documents={root:Jt()},this.currentDocument=this.documents.root,this.startEndCount=0,this.classes=Xt(),!e)this.links=new Map,C()}getState(e){return this.currentDocument.states.get(e)}getStates(){return this.currentDocument.states}logDocuments(){a.info("Documents = ",this.documents)}getRelations(){return this.currentDocument.relations}addLink(e,s,c){this.links.set(e,{url:s,tooltip:c}),a.warn("Adding link",e,s,c)}getLinks(){return this.links}startIdIfNeeded(e=""){if(e===B.START_NODE)return this.startEndCount++,`${B.START_TYPE}${this.startEndCount}`;return e}startTypeIfNeeded(e="",s=ut){return e===B.START_NODE?B.START_TYPE:s}endIdIfNeeded(e=""){if(e===B.END_NODE)return this.startEndCount++,`${B.END_TYPE}${this.startEndCount}`;return e}endTypeIfNeeded(e="",s=ut){return e===B.END_NODE?B.END_TYPE:s}addRelationObjs(e,s,c=""){let r=this.startIdIfNeeded(e.id.trim()),u=this.startTypeIfNeeded(e.id.trim(),e.type),f=this.startIdIfNeeded(s.id.trim()),m=this.startTypeIfNeeded(s.id.trim(),s.type);this.addState(r,u,e.doc,e.description,e.note,e.classes,e.styles,e.textStyles),this.addState(f,m,s.doc,s.description,s.note,s.classes,s.styles,s.textStyles),this.currentDocument.relations.push({id1:r,id2:f,relationTitle:b.sanitizeText(c,l())})}addRelation(e,s,c){if(typeof e==="object"&&typeof s==="object")this.addRelationObjs(e,s,c);else if(typeof e==="string"&&typeof s==="string"){let r=this.startIdIfNeeded(e.trim()),u=this.startTypeIfNeeded(e),f=this.endIdIfNeeded(s.trim()),m=this.endTypeIfNeeded(s);this.addState(r,u),this.addState(f,m),this.currentDocument.relations.push({id1:r,id2:f,relationTitle:c?b.sanitizeText(c,l()):void 0})}}addDescription(e,s){let c=this.currentDocument.states.get(e),r=s.startsWith(":")?s.replace(":","").trim():s;c?.descriptions?.push(b.sanitizeText(r,l()))}cleanupLabel(e){return e.startsWith(":")?e.slice(2).trim():e.trim()}getDividerId(){return this.dividerCnt++,`divider-id-${this.dividerCnt}`}addStyleClass(e,s=""){if(!this.classes.has(e))this.classes.set(e,{id:e,styles:[],textStyles:[]});let c=this.classes.get(e);if(s&&c)s.split(B.STYLECLASS_SEP).forEach((r)=>{let u=r.replace(/([^;]*);/,"$1").trim();if(RegExp(B.COLOR_KEYWORD).exec(r)){let m=u.replace(B.FILL_KEYWORD,B.BG_FILL).replace(B.COLOR_KEYWORD,B.FILL_KEYWORD);c.textStyles.push(m)}c.styles.push(u)})}getClasses(){return this.classes}setupToolTips(e){let s=Ft();p(e).select("svg").selectAll("g.node, g.rough-node").on("mouseover",(u)=>{let f=p(u.currentTarget),m=f.attr("title");if(m===null)return;let k=u.currentTarget?.getBoundingClientRect();s.transition().duration(200).style("opacity",".9"),s.style("left",window.scrollX+k.left+(k.right-k.left)/2+"px").style("top",window.scrollY+k.bottom+"px"),s.html(Re.sanitize(m)),f.classed("hover",!0)}).on("mouseout",(u)=>{s.transition().duration(500).style("opacity",0),p(u.currentTarget).classed("hover",!1)})}setCssClass(e,s){e.split(",").forEach((c)=>{let r=this.getState(c);if(!r){let u=c.trim();this.addState(u),r=this.getState(u)}r?.classes?.push(s)})}setStyle(e,s){this.getState(e)?.styles?.push(s)}setTextStyle(e,s){this.getState(e)?.textStyles?.push(s)}bindFunctions(e){this.funs.forEach((s)=>{s(e)})}getDirectionStatement(){return this.rootDoc.find((e)=>e.stmt===Ut)}getDirection(){return this.getDirectionStatement()?.value??_e}setDirection(e){let s=this.getDirectionStatement();if(s)s.value=e;else this.rootDoc.unshift({stmt:Ut,value:e})}trimColon(e){return e.startsWith(":")?e.slice(1).trim():e.trim()}getData(){let e=l();for(let s of this.nodes)if(s.wrappingWidth??=e.state?.wrappingWidth,!s.isGroup)s.minWidth??=e.state?.minNodeWidth;return{nodes:this.nodes,edges:this.edges,other:{},config:e,direction:Se(this.getRootDocV2())}}getConfig(){return l().state}},qe=t((e)=>{let{theme:s,bkgColorArray:c,borderColorArray:r}=e;if(!le(s,r))return"";let u=ce(e.look),f=pe(c),m="";for(let k=0;k<yt(r);k++){let o=r[k],D=f?`fill: ${c[k%c.length]};`:"",x=`[data-look="${u}"][data-color-id="color-${k}"]`;m+=`
|
|
7
7
|
|
|
8
8
|
/* The title strip: \`rect.outer\` spans the whole composite and \`rect.inner\` covers
|
|
9
9
|
the body, so what stays visible of \`outer\` is the band behind the label. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
2
|
-
export{
|
|
1
|
+
function Bn(i,d){let e;if(d===void 0){for(let n of i)if(n!=null&&(e<n||e===void 0&&n>=n))e=n}else{let n=-1;for(let f of i)if((f=d(f,++n,i))!=null&&(e<f||e===void 0&&f>=f))e=f}return e}function gn(i,d){let e;if(d===void 0){for(let n of i)if(n!=null&&(e>n||e===void 0&&n>=n))e=n}else{let n=-1;for(let f of i)if((f=d(f,++n,i))!=null&&(e>f||e===void 0&&f>=f))e=f}return e}
|
|
2
|
+
export{Bn,gn};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{g,o,v,i,r,f,e,n,y,st}from"./chunk-3k9h7a73.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),d=c%60;return d>0?`${a}m ${d}s`:`${a}m`}if(t<259200000){let c=Math.floor(t/60000),a=Math.floor(c/60),d=c%60;return d>0?`${a}h ${d}m`:`${a}h`}let u=Math.floor(t/3600000),b=Math.floor(u/24),p=u%24;return p>0?`${b}d ${p}h`:`${b}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 b=10**-u/100;if(t<b)return`<${(b*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("-"),b=u[1],p=u[2];if(b!==void 0&&p!==void 0)return`${b}/${p}`;return t}function Z(t){let u=t.split("-"),b=u[0],p=u[1],c=u[2];if(b===void 0||p===void 0||c===void 0)return t;let a=Number(b),d=Number(p)-1,h=Number(c),w=new Date(Date.UTC(a,d,h)),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 b=Math.max(0,u-t);if(b<60000)return"刚刚";if(b<3600000)return`${Math.max(1,Math.floor(b/60000))} 分钟前`;if(b<86400000)return`${Math.max(1,Math.floor(b/3600000))} 小时前`;if(b<2592000000)return`${Math.max(1,Math.floor(b/86400000))} 天前`;let p=new Date(t),c=p.getFullYear(),a=String(p.getMonth()+1).padStart(2,"0"),d=String(p.getDate()).padStart(2,"0");return`${c}-${a}-${d}`}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:b,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 d=a.projectID??V,h=b===d,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(h?null:d),className:"rounded px-1.5 py-0.5 text-[11px] text-accent hover:bg-accent/10 transition-colors cursor-pointer shrink-0",children:h?"取消筛选":"筛选"})]}),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()})," 次"]})]})]})]},d)})})}function re(t){let{models:u}=t,{ModelIcon:b,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(b,{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:b,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),d=c.successRate>=0.95?"success":c.successRate>=0.8?"warning":"danger",h=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(b,{tone:d,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:h.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:b}=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 d=c>0?Math.max(1,a.totalTokens/c*100):0,h=a.model.split("/").pop()??a.model;return n("button",{type:"button",onClick:()=>b(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(st,{className:"size-3.5 text-faint group-hover:text-ink group-hover:translate-x-0.5 transition-all"})]})]}),e(K,{percent:d}),n(Y,{children:[e(J,{stat:a}),n(G,{children:[e("span",{className:"text-ink",children:h}),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:b,SettingGroup:p,style:c}=y(),{daily:a}=t,[d,h]=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(d==="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(d==="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,d]),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(d==="tokens")return Math.max(1,...a.map((s)=>s.totalTokens));if(d==="duration")return Math.max(1000,...a.map((s)=>s.activeDurationMs));return Math.max(1,...a.map((s)=>s.assistantTurns+s.userMessages))},[a,d]),m=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(b,{value:d,onChange:(s)=>h(s),options:ce}),children:e("div",{className:c("surface.empty"),children:"当前时间范围内暂无活跃数据"})});return e(p,{title:"每日趋势",action:e(b,{value:d,onChange:(s)=>h(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:[d==="tokens"&&n(f,{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"}),"输出"]})]}),d==="duration"&&n(f,{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"}),"模型推理"]})]}),d==="activity"&&n(f,{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(d==="duration")l=s.activeDurationMs;else if(d==="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:[d==="tokens"&&n(f,{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}%`}})]}),d==="duration"&&n(f,{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"})]}),d==="activity"&&n(f,{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:m.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(f,{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:b}=y(),{daily:p,hourly:c}=t,[a,d]=r(null),h=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=h[0];for(let x of h)if(!l||x.totalTokens>l.totalTokens)l=x;return l&&l.totalTokens>0?l:null},[h]),C=v(()=>h.reduce((l,x)=>l+x.totalTokens,0),[h]),D=v(()=>Math.max(1,...h.map((l)=>l.totalTokens)),[h]),F=v(()=>{if(C<=0)return 0;return h.filter((x)=>x.hour>=8&&x.hour<20).reduce((x,T)=>x+T.totalTokens,0)/C},[h,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]),m=v(()=>p.filter((l)=>l.totalTokens>0||l.activeDurationMs>0||l.runs>0).length,[p]),s=a!==null?h[a]:w;return n(b,{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:["活跃 ",m,"/",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:()=>d(null),children:[e("div",{className:"flex-1 flex items-end gap-1.5 pb-1.5",children:h.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,st}from"./chunk-ve8gy05p.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(st,{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
|
-
助手轮次: ${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:()=>
|
|
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)}
|
|
5
5
|
消耗: ${L(l.totalTokens)} Token
|
|
6
6
|
耗时: ${P(l.activeDurationMs)}
|
|
7
|
-
助手轮次: ${l.assistantTurns} 轮`;return e("div",{className:u("size-3.5 rounded-xs transition-transform hover:scale-125 cursor-pointer",x),title:T},l.date)})})]})]})}var xe=[{value:"7d",label:"近 7 天"},{value:"30d",label:"近 30 天"},{value:"90d",label:"近 90 天"},{value:"all",label:"全部"}],q=new Map,me=[];function X(t,u){return`${t}:${u??"all"}`}function Le(t){let{connection:u,onOpen:
|
|
7
|
+
助手轮次: ${l.assistantTurns} 轮`;return e("div",{className:u("size-3.5 rounded-xs transition-transform hover:scale-125 cursor-pointer",x),title:T},l.date)})})]})]})}var xe=[{value:"7d",label:"近 7 天"},{value:"30d",label:"近 30 天"},{value:"90d",label:"近 90 天"},{value:"all",label:"全部"}],q=new Map,me=[];function X(t,u){return`${t}:${u??"all"}`}function Le(t){let{connection:u,onOpen:g}=t,{Button:p,PageLayout:c,Segmented:a,SettingGroup:f,style:b}=y(),[w,C]=r("30d"),[D,F]=r(null),[j,z]=r("projects"),[d,s]=r(()=>q.get(X("30d",null))??null),[l,x]=r(()=>!q.has(X("30d",null))),[T,k]=r(null),[H,S]=r(()=>me),R=i(0),N=h(async()=>{let A=++R.current,O=X(w,D),ee=q.get(O);if(ee)s(ee);x(!0);try{let E=new URLSearchParams({range:w,tzOffset:String(new Date().getTimezoneOffset())});if(D)E.set("projectID",D);let U=await u.request(`/api/stats?${E.toString()}`);if(A!==R.current)return;if(q.set(O,U),s(U),k(null),U.projects)S((de)=>{let te=new Map(de.map((I)=>[I.id,I.name]));for(let I of U.projects)if(I.projectID)te.set(I.projectID,I.name);let ne=Array.from(te.entries()).map(([I,fe])=>({id:I,name:fe}));return me=ne,ne})}catch(E){if(A===R.current)k(E instanceof Error?E.message:"加载统计数据失败")}finally{if(A===R.current)x(!1)}},[u,w,D]);o(()=>(N(),()=>{R.current++}),[N]);let _=v(()=>{if(!D)return null;if(D===V)return"独立聊天";return(H.find((O)=>O.id===D)??d?.projects.find((O)=>O.projectID===D))?.name??"指定项目"},[D,H,d]);return n(c,{title:_?n(m,{children:["统计 ",n("span",{className:"text-dim",children:["· ",_]})]}):"统计",description:"按项目、模型与工具统计活跃耗时与 Token 消耗。",actions:n(m,{children:[D&&e(p,{size:"sm",variant:"ghost",onClick:()=>F(null),children:"返回全部"}),e(a,{value:w,onChange:C,options:xe})]}),children:[T&&n("div",{className:"mb-4 flex items-center justify-between rounded-lg bg-danger/10 px-3 py-2 text-xs text-danger",children:[e("span",{children:T}),e(p,{size:"sm",variant:"ghost",onClick:()=>{N()},className:"text-danger hover:text-danger",children:"重试"})]}),l&&!d?e("div",{className:"flex justify-center py-12 text-xs text-faint",children:"正在加载统计…"}):!d?e("div",{className:b("surface.card","p-12 text-center text-sm text-dim"),children:"暂无统计数据"}):n("div",{className:"space-y-8",children:[e(f,{title:"核心总览",unboxed:!0,children:n("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[n("div",{className:b("surface.card","p-4"),children:[n("div",{className:"flex items-center justify-between gap-2 text-xs text-faint",children:[e("span",{children:"总 Token 消耗"}),n("span",{className:"font-mono tabular-nums",children:["缓存命中 ",B(d.overview.cacheHitRate)]})]}),e("div",{className:"mt-1.5 font-mono text-xl font-semibold tracking-tight text-ink tabular-nums",title:`${L(d.overview.totalTokens)} Token`,children:M(d.overview.totalTokens)}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:[n("span",{children:["输入 ",M(d.overview.inputTokens)]}),n("span",{children:["输出 ",M(d.overview.outputTokens)]}),n("span",{children:["缓存读 ",M(d.overview.cacheReadTokens)]})]})]}),n("div",{className:b("surface.card","p-4"),children:[n("div",{className:"flex items-center justify-between gap-2 text-xs text-faint",children:[e("span",{children:"活跃工作耗时"}),n("span",{className:"font-mono tabular-nums",children:["日均"," ",d.overview.activeDays>0?P(d.overview.activeDurationMs/d.overview.activeDays):"0s"]})]}),e("div",{className:"mt-1.5 font-mono text-xl font-semibold tracking-tight text-ink tabular-nums",children:P(d.overview.activeDurationMs)}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:[n("span",{children:["模型推理 ",P(d.overview.generationMs)]}),n("span",{children:["并发累计 ",P(d.overview.cumulativeRunDurationMs)]})]})]}),n("div",{className:b("surface.card","p-4"),children:[n("div",{className:"flex items-center justify-between gap-2 text-xs text-faint",children:[e("span",{children:"会话与工作流"}),n("span",{className:"font-mono tabular-nums",children:[d.overview.activeProjects,"/",d.overview.totalProjects," 活跃项目"]})]}),n("div",{className:"mt-1.5 font-mono text-xl font-semibold tracking-tight text-ink tabular-nums",children:[d.overview.sessionCount.toLocaleString()," 个会话"]}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:[n("span",{children:[d.overview.mainSessionCount," 主会话 / ",d.overview.subSessionCount," 子代理"]}),n("span",{children:[d.overview.userMessages," 提问 / ",d.overview.assistantTurns," 回复"]})]})]}),n("div",{className:b("surface.card","p-4"),children:[n("div",{className:"flex items-center justify-between gap-2 text-xs text-faint",children:[e("span",{children:"吞吐效率与调用"}),n("span",{className:"font-mono tabular-nums",children:[d.overview.compactions," 次折叠"]})]}),e("div",{className:"mt-1.5 font-mono text-xl font-semibold tracking-tight text-ink tabular-nums",children:d.overview.avgTps!==null?`${d.overview.avgTps.toFixed(1)} tok/s`:`${d.overview.toolCalls.toLocaleString()} 次调用`}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:[n("span",{children:[d.overview.toolCalls.toLocaleString()," 次工具调用"]}),n("span",{children:[d.overview.runCount.toLocaleString()," 次运行"]})]})]})]})}),e(ue,{daily:d.daily}),e(pe,{daily:d.daily,hourly:d.hourly}),e(f,{title:"分类明细",action:e(a,{value:j,onChange:z,options:[{value:"projects",label:`项目消耗 (${d.projects.length})`},{value:"models",label:`模型分析 (${d.models.length})`},{value:"tools",label:`工具调用 (${d.tools.length})`},{value:"sessions",label:`高消耗会话 (${d.topSessions.length})`}]}),children:n("div",{className:"animate-fade",children:[j==="projects"&&e(oe,{projects:d.projects,selectedProjectID:D,onSelectProject:F,onOpenSession:g}),j==="models"&&e(re,{models:d.models}),j==="tools"&&e(ie,{tools:d.tools}),j==="sessions"&&e(le,{sessions:d.topSessions,onOpenSession:g})]},j)})]})]})}export{Le as StatsPage};
|