@bkm016/basalt 0.1.3 → 0.1.4
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-x1xss1d7.js → chunk-1vd0f74z.js} +2 -2
- package/{chunk-v9fea96h.js → chunk-2hbfk5xd.js} +2 -2
- package/{chunk-5j1krv9v.js → chunk-2zp1mv3q.js} +1 -1
- package/{chunk-d2j735sd.js → chunk-3ct2tkr8.js} +2 -2
- package/{chunk-c7x1zq39.js → chunk-3x94302m.js} +1 -1
- package/{chunk-gzxnene8.js → chunk-4w17tzp5.js} +2 -2
- package/{chunk-1zdwrgd4.js → chunk-5dfbezv9.js} +1 -1
- package/{chunk-bxn5kmpz.js → chunk-5x1sankd.js} +24 -24
- package/{chunk-pmqtkqsf.js → chunk-71h08f4g.js} +1 -1
- package/{chunk-fm0k0qtz.js → chunk-7afmgncg.js} +2 -2
- package/{chunk-v258nxcz.js → chunk-7nzhdrv9.js} +1 -1
- package/{chunk-zmsgwr3s.js → chunk-7q51n619.js} +1 -1
- package/{chunk-y0m980k3.js → chunk-7tbya5b5.js} +3 -3
- package/{chunk-8tjad3r0.js → chunk-8wc8qdx8.js} +5 -5
- package/{chunk-gp7y0fja.js → chunk-9rmqgc3c.js} +9 -9
- package/{chunk-nbb9trwz.js → chunk-akr0a8nc.js} +2 -2
- package/{chunk-k506w58v.js → chunk-aky4tztg.js} +2 -2
- package/{chunk-8296hw9m.js → chunk-em187cy3.js} +2 -2
- package/{chunk-2esbgxps.js → chunk-ev6yvy5y.js} +5 -5
- package/{chunk-75m78j7x.js → chunk-f3xadvab.js} +2 -2
- package/{chunk-5c9j8qe4.js → chunk-fvn32nzj.js} +26 -26
- package/{chunk-bannb9xm.js → chunk-jk25nt60.js} +1 -1
- package/{chunk-27gntzs5.js → chunk-kp22kaez.js} +1 -1
- package/{chunk-6hssbcgj.js → chunk-nmca5h6m.js} +1 -1
- package/{chunk-d8gtbw9g.js → chunk-pjyn2s97.js} +1 -1
- package/{chunk-rtzqqngy.js → chunk-q7t30zz2.js} +2 -2
- package/{chunk-aefadsy6.js → chunk-r0scgfwx.js} +1 -1
- package/{chunk-hwr56pfj.js → chunk-rmj5b73e.js} +1 -1
- package/{chunk-1qpces5a.js → chunk-vexrrw1b.js} +2 -2
- package/chunk-vkpvcxjr.js +2 -0
- package/{chunk-3cjsd292.js → chunk-whvj83b7.js} +2 -2
- package/{chunk-z55bmysw.js → chunk-xh3vr5vz.js} +1 -1
- package/{chunk-10xzzn07.js → chunk-zggzfa7j.js} +2 -2
- package/compiled.js +3 -3
- package/package.json +1 -1
- package/ui-test-worker.js +13 -13
- package/web/{chunk-7520nrbb.js → chunk-0b47eyrf.js} +1 -1
- package/web/{chunk-g46f421r.js → chunk-0h0vb6gt.js} +1 -1
- package/web/{chunk-h18tnrf2.js → chunk-0rmkpsgp.js} +1 -1
- package/web/{chunk-t7bwsdbr.js → chunk-0xkyryrq.js} +1 -1
- package/web/{chunk-h288yd5w.js → chunk-0z0y25zf.js} +1 -1
- package/web/{chunk-7ba8vrfc.js → chunk-1eg9sbbt.js} +1 -1
- package/web/{chunk-p9hsd3rn.js → chunk-1gbd61z0.js} +1 -1
- package/web/{chunk-vd6y2pcm.js → chunk-2s0bmrkv.js} +1 -1
- package/web/{chunk-33qwz9bc.js → chunk-2z1rwr28.js} +1 -1
- package/web/{chunk-tse9gvyq.js → chunk-344bq59c.js} +1 -1
- package/web/{chunk-0z0jycs8.js → chunk-3re8y26v.js} +1 -1
- package/web/chunk-3t0211rw.js +1 -0
- package/web/{chunk-5hmfk69r.js → chunk-42e3b9hv.js} +1 -1
- package/web/chunk-44rmrmcn.js +1 -0
- package/web/{chunk-fhnypcrm.js → chunk-4bzqrwr0.js} +81 -81
- package/web/{chunk-j0bwwc1g.js → chunk-4d3a7xs2.js} +1 -1
- package/web/{chunk-y3ajqthy.js → chunk-4jmazh6x.js} +1 -1
- package/web/{chunk-z4x331rx.js → chunk-4re74xwm.js} +1 -1
- package/web/{chunk-61jahh35.js → chunk-5qtyq3ce.js} +1 -1
- package/web/{chunk-wmvd6j0b.js → chunk-5z4jcqct.js} +1 -1
- package/web/{chunk-fv60p68p.js → chunk-5z6x2n5h.js} +1 -1
- package/web/{chunk-sn9ecfvy.js → chunk-6cnek1xh.js} +1 -1
- package/web/chunk-6f5ke0x9.js +1 -0
- package/web/{chunk-3qjnwsph.js → chunk-6xaqxcq8.js} +1 -1
- package/web/chunk-7q6wvv2x.js +1 -0
- package/web/{chunk-cwtdnacf.js → chunk-7qsa4p8h.js} +1 -1
- package/web/chunk-8nja0ygy.js +1 -0
- package/web/{chunk-z6bpamwq.js → chunk-8y64fkpz.js} +1 -1
- package/web/{chunk-90xqeczk.js → chunk-92ssjk2y.js} +1 -1
- package/web/chunk-9ad7v7bm.js +8 -0
- package/web/{chunk-7yc083xj.js → chunk-9cx1be43.js} +1 -1
- package/web/{chunk-wdtnhpd6.js → chunk-9dzxv335.js} +1 -1
- package/web/{chunk-w7snhcyg.js → chunk-9t5dnjaz.js} +2 -2
- package/web/{chunk-7v5rxabp.js → chunk-a408enpy.js} +1 -1
- package/web/{chunk-hszjc2ny.js → chunk-a497tykb.js} +1 -1
- package/web/{chunk-n8gfjj9a.js → chunk-aqfpnhmt.js} +2 -2
- package/web/{chunk-axkyft9f.js → chunk-b1bgzz66.js} +1 -1
- package/web/{chunk-sb1cjpq8.js → chunk-b53bfkys.js} +1 -1
- package/web/{chunk-6parf7sy.js → chunk-b6k9w215.js} +1 -1
- package/web/{chunk-es28k2t7.js → chunk-bhsaj6qq.js} +1 -1
- package/web/chunk-cjfssg3m.js +2 -0
- package/web/{chunk-5qqw2e0t.js → chunk-d11v5s7w.js} +1 -1
- package/web/{chunk-acybsx44.js → chunk-df5zx17h.js} +1 -1
- package/web/chunk-e0zre35a.js +1 -0
- package/web/{chunk-a5sg33w2.js → chunk-e9twvs9n.js} +1 -1
- package/web/chunk-f2kgtyfp.js +1 -0
- package/web/{chunk-23c1df7e.js → chunk-f4tacm06.js} +1 -1
- package/web/chunk-f8bn5tzf.js +1 -0
- package/web/chunk-fdp9bsj7.js +1 -0
- package/web/{chunk-7xk0ntav.js → chunk-fh2vj0wv.js} +1 -1
- package/web/{chunk-sgvp8vge.js → chunk-gmzqdm7v.js} +1 -1
- package/web/{chunk-tx8240k4.js → chunk-hvw3gn2a.js} +1 -1
- package/web/{chunk-rks7ksv3.js → chunk-khxcn8tt.js} +1 -1
- package/web/{chunk-eqsd8zta.js → chunk-kmr7r9xj.js} +1 -1
- package/web/chunk-kqqmp1am.js +1 -0
- package/web/{chunk-mb4qx9hy.js → chunk-kwccs9f6.js} +1 -1
- package/web/chunk-nbgqbxcy.js +1 -0
- package/web/{chunk-rcx1aee5.js → chunk-ncpnpe9w.js} +1 -1
- package/web/{chunk-jzfd7cyh.js → chunk-ne0v8mfb.js} +1 -1
- package/web/{chunk-yd1ez3wd.js → chunk-ngx2cp8x.js} +1 -1
- package/web/{chunk-4fzj0azw.js → chunk-nvhmq4z5.js} +1 -1
- package/web/chunk-nxcgf7ec.js +1 -0
- package/web/{chunk-zmdnxn6m.js → chunk-p0kvmf28.js} +1 -1
- package/web/chunk-p3k7m5nr.js +1 -0
- package/web/{chunk-9bgey148.js → chunk-pggaffrh.js} +1 -1
- package/web/{chunk-5b2nw6j1.js → chunk-pjkdrgm0.js} +1 -1
- package/web/{chunk-97b62pvb.js → chunk-pws2seas.js} +1 -1
- package/web/{chunk-mwj9tpkz.js → chunk-pz9ps2jm.js} +1 -1
- package/web/chunk-qpmbxhh6.js +1 -0
- package/web/chunk-r0rctnxz.js +1 -0
- package/web/chunk-rn3dnqm8.js +1 -0
- package/web/{chunk-47q4hmfp.js → chunk-rvrf0f3h.js} +1 -1
- package/web/{chunk-7qxhk1kz.js → chunk-sfg2wkhe.js} +1 -1
- package/web/{chunk-ep37qp12.js → chunk-sspfxp5e.js} +1 -1
- package/web/{chunk-2hd1pe9w.js → chunk-t4c8xavd.js} +1 -1
- package/web/{chunk-8qgpfxkz.js → chunk-tdr6x2xc.js} +1 -1
- package/web/chunk-tncvg1nn.js +1 -0
- package/web/{chunk-9xh96b33.js → chunk-vyp0ns1f.js} +1 -1
- package/web/{chunk-b0a8nbj0.js → chunk-wnskxerq.js} +1 -1
- package/web/{chunk-vymqrpm3.js → chunk-wvdehm9y.js} +66 -66
- package/web/chunk-x7ahcpj7.js +1 -0
- package/web/chunk-y38bf0wm.js +1 -0
- package/web/{chunk-89fkdgbp.js → chunk-y56aaba5.js} +1 -1
- package/web/{chunk-24h1rfje.js → chunk-ybrf9mhz.js} +1 -1
- package/web/{chunk-vpa55vje.js → chunk-ye58t45p.js} +3 -3
- package/web/{chunk-xnq41dgs.js → chunk-yqbnps3a.js} +1 -1
- package/web/{chunk-jqa39f8t.js → chunk-z1h20s8c.js} +1 -1
- package/web/{chunk-9a3q0jsh.js → chunk-zj4q9jth.js} +1 -1
- package/web/{chunk-ywp4s71k.js → chunk-zj5k94dk.js} +1 -1
- package/web/{chunk-xvsmtetz.js → chunk-zqch0sc8.js} +1 -1
- package/web/{chunk-0xc2c540.js → chunk-zx8zec24.js} +1 -1
- package/web/index.html +1 -1
- package/chunk-09rj27b2.js +0 -2
- package/web/chunk-166qe5j6.js +0 -2
- package/web/chunk-1c95wfvq.js +0 -1
- package/web/chunk-329rtxa9.js +0 -1
- package/web/chunk-6gxf3vsg.js +0 -1
- package/web/chunk-a91vxtx4.js +0 -1
- package/web/chunk-agec7jj4.js +0 -1
- package/web/chunk-c516cghj.js +0 -1
- package/web/chunk-dg1vas6z.js +0 -8
- package/web/chunk-fc0nx23g.js +0 -1
- package/web/chunk-jvbbrnpa.js +0 -1
- package/web/chunk-ka9ak8wr.js +0 -1
- package/web/chunk-mnjd59jk.js +0 -1
- package/web/chunk-ng0nbfhh.js +0 -1
- package/web/chunk-nz9nxk48.js +0 -1
- package/web/chunk-phw908hn.js +0 -1
- package/web/chunk-pjmmma1k.js +0 -1
- package/web/chunk-q7yn4m3t.js +0 -1
- package/web/chunk-qnhqexe0.js +0 -1
- package/web/chunk-rjqj6ffe.js +0 -1
- package/web/chunk-sjjwte12.js +0 -1
- package/web/chunk-yfbxtg5p.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h,o,i,a,v,t,n,_,l,Z,gt,yt,un,ve,Re,te,de,jt,ot,re,tn,oe}from"./chunk-fhnypcrm.js";var Se=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],fe=l("key-round",Se);function ge(e){let d=[],g="",y,N=!1;for(let u=0;u<e.length;u++){let c=e[u];if(y)if(c===y)y=void 0;else if(c==="\\"&&y==='"'&&u+1<e.length)g+=e[++u];else g+=c;else if(c==='"'||c==="'")y=c,N=!0;else if(c==="\\"&&u+1<e.length)g+=e[++u],N=!0;else if(/\s/.test(c)){if(N||g)d.push(g);g="",N=!1}else g+=c,N=!0}if(N||g)d.push(g);return d}function le(e){return e.map((d)=>d===""||/[\s"'\\]/.test(d)?`"${d.replace(/(["\\])/g,"\\$1")}"`:d).join(" ")}var xe="size-4 cursor-pointer rounded border-line text-accent accent-accent focus-visible:outline-2 focus-visible:outline-accent",je={connected:{label:"已连接",dot:"bg-success"},idle:{label:"待连接",dot:"bg-faint"},disabled:{label:"已停用",dot:"bg-faint"},failed:{label:"连接失败",dot:"bg-danger"},needs_auth:{label:"需要认证",dot:"bg-warning"}};function X(e){return e.type==="local"?le(e.command):e.url}function he({info:e,tools:d=!1}){let g=je[e.status.status];return n("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs text-dim",children:[t("span",{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full ${g.dot}`}),t("span",{className:d?void 0:"hidden @md/panel:inline",children:g.label}),d&&e.status.status==="connected"&&n("span",{className:"text-faint",children:["· ",e.toolCount," 个工具"]})]})}function Te(e){if(typeof e!=="object"||e===null||!("type"in e))return"any";let d=e.type;if(typeof d==="string")return d;if(Array.isArray(d))return d.filter((g)=>typeof g==="string").join(" | ")||"any";return"any"}function be(e){let{Button:d,CopyButton:g,Dialog:y,StatusChip:N,confirm:u,style:c,useTheme:k}=_();k();let{info:s,connection:I}=e,[m,q]=a(),[G,K]=a(),[S,j]=a(!1),W=s.status.status==="connected",z=s.status.status==="needs_auth",V=s.status.status==="failed",A=s.config.type==="remote"&&Boolean(s.config.oauth);o(()=>{function p(x){if(x&&x!==s.name)return;let J=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"";I.request(`/api/mcp/${encodeURIComponent(s.name)}/connect${J}`,{method:"POST"}).then((ee)=>e.onChanged(ee)).catch(()=>{})}function f(x){if(x.data?.type==="mcp-oauth-success")p(x.data.name)}function D(x){if(x.key==="basalt-mcp-oauth-event"&&x.newValue)try{let J=JSON.parse(x.newValue);p(J.name)}catch(J){}}window.addEventListener("message",f),window.addEventListener("storage",D);let R;if("BroadcastChannel"in window)R=new BroadcastChannel("basalt-mcp-oauth"),R.onmessage=(x)=>{if(x.data?.type==="mcp-oauth-success")p(x.data.name)};return()=>{window.removeEventListener("message",f),window.removeEventListener("storage",D),R?.close()}},[I,s.name,s.projectID,e]),o(()=>{if(s.status.status!=="connected")return;let p=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"";I.request(`/api/mcp/${encodeURIComponent(s.name)}/tools${p}`).then((f)=>{if(Array.isArray(f))q(f),K(void 0)}).catch((f)=>{K(f instanceof Error?f.message:"获取工具失败")})},[I,s.name,s.projectID,s.status.status]);async function O(p){j(!0);try{let f=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"",D=await I.request(`/api/mcp/${encodeURIComponent(s.name)}/${p}${f}`,{method:"POST"});e.onChanged(D)}catch{}finally{j(!1)}}async function U(){j(!0);try{let p=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"",f=s.status.status==="needs_auth"?s.status.authorizationUrl:void 0;if(!f)f=(await I.request(`/api/mcp/${encodeURIComponent(s.name)}/oauth/authorize${p}`,{method:"POST"})).authorizationUrl;if(f)window.open(f,"_blank","width=600,height=700")}catch(p){K(p instanceof Error?p.message:"获取授权链接失败")}finally{j(!1)}}async function Y(){j(!0);try{let p=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"",f=await I.request(`/api/mcp/${encodeURIComponent(s.name)}/oauth/clear${p}`,{method:"POST"});e.onChanged(f)}finally{j(!1)}}async function E(){if(!await u({title:`删除 ${s.name}?`,description:"删除后将断开连接并不再向会话提供其工具。",action:"删除",danger:!0}))return;j(!0);try{let f=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"";await I.request(`/api/mcp/${encodeURIComponent(s.name)}${f}`,{method:"DELETE"}),e.onChanged(),e.onClose()}finally{j(!1)}}let T=s.config,r=X(T),C="error"in s.status?s.status.error:void 0,M=m?.length??s.toolCount??0;return t(y,{open:!0,className:"bg-panel shadow-float",onOpenChange:(p)=>{if(!p&&!S)e.onClose()},title:n("div",{className:"flex flex-wrap items-center gap-3",children:[t("div",{className:"flex size-8 items-center justify-center rounded-[10px] border border-accent/20 bg-accent-soft text-accent",children:T.type==="local"?t(ot,{className:"size-4"}):t(ve,{className:"size-4"})}),t("span",{className:"font-serif text-lg font-semibold tracking-tight text-ink",children:s.name}),W?t(N,{tone:"success",pulse:!0,children:"已连接"}):z?t(N,{tone:"warning",pulse:!0,children:"需要授权"}):V?t(N,{tone:"danger",children:"连接失败"}):s.status.status==="disabled"?t(N,{tone:"neutral",children:"已停用"}):t(N,{tone:"neutral",children:"未连接"})]}),description:n("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5 text-xs",children:[n("span",{className:"flex min-w-0 max-w-full items-center gap-1 rounded-lg border border-line bg-raised/60 py-0.5 pr-1 pl-2.5 font-mono text-[11.5px] text-ink",children:[t("span",{className:"min-w-0 truncate",title:r,children:r}),t(g,{text:r,label:"复制地址",size:"icon-xs",className:"shrink-0 text-dim hover:text-ink"})]}),t("span",{className:"rounded-lg border border-line px-2 py-1 text-[11px] leading-none text-dim",children:T.type==="local"?"本地命令":"远程 HTTP"}),A&&n("span",{className:c("control.badgeAccent","gap-1 rounded-lg border border-accent/25 px-2 py-1"),children:[t(jt,{className:"size-3"}),"OAuth 2.0"]})]}),size:"lg",footer:n("div",{className:"flex w-full items-center justify-between gap-2 max-sm:flex-col",children:[n("div",{className:"flex items-center gap-1 max-sm:w-full",children:[A&&t(d,{type:"button",variant:"ghost",onClick:Y,disabled:S,title:"清除已保存的 OAuth 凭据",children:"清除凭据"}),t(d,{type:"button",variant:"danger-ghost",size:"icon-sm","aria-label":"删除服务器",onClick:E,disabled:S,title:"删除服务器",children:t(re,{className:"size-4"})})]}),n("div",{className:"flex items-center gap-2 max-sm:w-full max-sm:justify-end",children:[t(d,{type:"button",variant:"ghost",onClick:e.onEdit,disabled:S,children:"编辑配置"}),!z&&t(d,{type:"button",variant:"secondary",onClick:()=>O(W?"disconnect":"connect"),disabled:S,children:S?"处理中...":W?"断开连接":"立即连接"}),t(d,{type:"button",variant:"primary",onClick:e.onClose,children:"完成"})]})]}),children:n("div",{className:"space-y-6 pt-1",children:[z&&t("div",{className:"relative overflow-hidden rounded-2xl border border-warning/30 bg-[radial-gradient(120%_140%_at_0%_0%,color-mix(in_oklch,var(--color-warning)_16%,transparent),transparent_65%)] p-5",children:n("div",{className:"flex items-start gap-4 max-sm:flex-col",children:[t("div",{className:"relative flex size-11 shrink-0 items-center justify-center rounded-xl border border-warning/30 bg-panel text-warning shadow-[0_0_28px_-4px_color-mix(in_oklch,var(--color-warning)_55%,transparent)]",children:t(fe,{className:"size-5"})}),n("div",{className:"min-w-0 flex-1 space-y-1.5",children:[t("h4",{className:"text-sm font-semibold text-ink",children:"授权后即可使用此服务器"}),t("p",{className:"text-[13px] leading-relaxed text-dim",children:"该端点要求 OAuth 2.0 身份许可。在浏览器中完成授权后,令牌会自动保存并载入全部工具。"}),C&&t("p",{className:"line-clamp-2 break-words font-mono text-[11.5px] text-faint",title:C,children:C})]}),n(d,{type:"button",variant:"primary",onClick:U,disabled:S,className:"shrink-0",children:[t(un,{className:"mr-1.5 size-3.5"}),S?"正在拉起授权...":"前往授权"]})]})}),V&&n("div",{className:c("callout.base",c("callout.danger"),"gap-3 rounded-2xl p-4"),children:[t(gt,{className:"mt-0.5 size-4 shrink-0 text-danger"}),n("div",{className:"min-w-0 space-y-1",children:[t("h4",{className:"text-sm font-medium text-ink",children:"连接失败"}),t("p",{className:"font-mono text-[11.5px] leading-relaxed break-words text-dim",children:C})]})]}),n("section",{className:"space-y-3",children:[n("div",{className:"flex items-baseline justify-between gap-3 px-0.5",children:[n("h4",{className:"flex items-center gap-2 text-[13px] font-medium text-ink",children:["可用工具",t("span",{className:"rounded-full bg-raised px-1.5 py-0.5 font-mono text-[11px] leading-none text-dim",children:M})]}),t("span",{className:"text-[11.5px] text-faint",children:"对所有会话可用"})]}),G?t("div",{className:c("callout.base",c("callout.danger"),"text-xs leading-relaxed break-words"),children:G}):!W?n("div",{className:c("surface.emptyDashed","gap-2 py-10"),children:[t("div",{className:"flex size-10 items-center justify-center rounded-full bg-raised text-faint",children:t(tn,{className:"size-4.5"})}),t("p",{className:"text-[13px] font-medium text-dim",children:z?"等待授权":"尚未连接"}),t("p",{className:"max-w-xs text-xs leading-relaxed text-faint",children:z?"授权完成后会自动连接并列出工具。":"连接服务器后,这里会列出它提供的全部工具。"})]}):!m?t("div",{role:"status","aria-label":"正在获取工具列表",className:"grid gap-2",children:[0,1,2].map((p)=>n("div",{className:"animate-pulse space-y-2.5 rounded-xl border border-line p-3.5",children:[t("div",{className:"h-3.5 w-32 rounded bg-raised"}),t("div",{className:"h-3 w-4/5 rounded bg-raised/70"})]},p))}):m.length===0?n("div",{className:c("surface.emptyDashed","gap-2 py-10"),children:[t("div",{className:"flex size-10 items-center justify-center rounded-full bg-raised text-faint",children:t(tn,{className:"size-4.5"})}),t("p",{className:"text-[13px] font-medium text-dim",children:"没有可用工具"}),t("p",{className:"max-w-xs text-xs leading-relaxed text-faint",children:"已连接成功,但该服务器没有声明任何工具。"})]}):t("ul",{className:"grid gap-2",children:m.map((p)=>{let f=p.inputSchema?.properties??{},D=p.inputSchema?.required??[],R=Object.entries(f);return n("li",{className:c("surface.subtle","border-line bg-raised/30 p-3.5 transition-colors hover:border-line-strong hover:bg-raised/60"),children:[t("span",{className:"font-mono text-[13px] font-medium break-all text-accent",children:p.name}),p.description&&t("p",{className:"mt-1.5 text-[13px] leading-relaxed break-words text-dim",children:p.description}),R.length>0&&t("div",{className:"mt-3 flex flex-wrap gap-1.5",children:R.map(([x,J])=>n("span",{title:D.includes(x)?"必填参数":"可选参数",className:"inline-flex items-center gap-1 rounded-md border border-line bg-panel px-1.5 py-1 font-mono text-[11px] leading-none",children:[t("span",{className:"text-ink",children:x}),D.includes(x)&&t("span",{className:"text-warning",children:"*"}),t("span",{className:"text-faint",children:Te(J)})]},x))})]},p.name)})})]})]})})}var $e=/^[A-Za-z0-9_-]{1,64}$/;function H(e){return t("span",{className:"truncate text-xs text-faint",children:e.children})}function ye(e){let{pairs:d,onChange:g,InputComponent:y}=e,N=(u,c)=>g(d.map((k,s)=>s===u?{...k,...c}:k));return n("div",{className:"space-y-2",children:[n("div",{className:"flex min-h-7 items-center gap-2",children:[t("span",{className:"shrink-0 text-[13px] font-medium text-dim",children:e.label}),t(H,{children:e.tip}),n("button",{type:"button",className:"ml-auto inline-flex h-7 shrink-0 cursor-pointer items-center gap-1 rounded-lg px-2 text-xs font-medium text-dim transition-colors hover:bg-raised hover:text-ink",onClick:()=>g([...d,{key:"",value:"",saved:!1}]),children:[t(Re,{className:"size-3.5"}),"添加"]})]}),d.map((u,c)=>n("div",{className:"flex min-w-0 items-center gap-1.5",children:[t(y,{"aria-label":`${e.keyLabel} ${c+1}`,placeholder:e.keyLabel,value:u.key,readOnly:u.saved,onChange:(k)=>N(c,{key:k.target.value}),className:"min-w-0 flex-[2] font-mono text-xs"}),t(y,{"aria-label":`${e.keyLabel} ${u.key||c+1} 的值`,type:"password",autoComplete:"off",placeholder:u.saved?"已保存,留空保持不变":"值",value:u.value,onChange:(k)=>N(c,{value:k.target.value}),className:"min-w-0 flex-[3] font-mono text-xs"}),t("button",{type:"button","aria-label":`删除 ${u.key||"该项"}`,className:"flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-faint transition-colors hover:bg-danger/10 hover:text-danger",onClick:()=>g(d.filter((k,s)=>s!==c)),children:t(oe,{className:"size-4"})})]},c))]})}function Ne(e){return Object.keys(e??{}).map((d)=>({key:d,value:"",saved:!0}))}function Ce(e){let{Button:d,Segmented:g,Dialog:y,Form:N,Field:u,Input:c,Switch:k,style:s,useTheme:I}=_();I();let{existing:m}=e,[q,G]=a(m?.config.type??"local"),[K,S]=a(m?.name??""),[j,W]=a(m?.config.type==="local"?le(m.config.command):""),[z,V]=a(m?.config.type==="remote"?m.config.url:""),[A,O]=a(Ne(m?.config.type==="local"?m.config.environment:void 0)),[U,Y]=a(Ne(m?.config.type==="remote"?m.config.headers:void 0)),E=m?.config.type==="remote"?m.config.oauth:void 0,[T,r]=a(Boolean(E)),[C,M]=a(typeof E==="object"&&E.clientId?E.clientId:""),[p,f]=a(""),[D,R]=a(typeof E==="object"&&E.scope?E.scope:""),[x,J]=a(m?.config.defer??"default"),[ee,we]=a(m?.config.timeout!==void 0?String(m.config.timeout):""),[se,ke]=a(m?.config.defer!==void 0||m?.config.timeout!==void 0),[me,Q]=a(),[ie,pe]=a(!1);async function Ie(b){b.preventDefault(),Q(void 0);let w=K.trim();if(!m&&!$e.test(w)){Q("名称只能包含英文字母、数字、下划线与中划线,长度 1-64");return}if(!m&&e.taken.includes(w)){Q("同名服务器已存在");return}let ne=ee.trim()?Number.parseInt(ee.trim(),10):void 0;if(ne!==void 0&&(!Number.isFinite(ne)||ne<=0)){Q("超时时间须为大于 0 的毫秒数");return}let ce;if(q==="local"){let L=ge(j.trim());if(!L.length){Q("请输入启动命令");return}let F={};for(let B of A){let P=B.key.trim();if(!P)continue;if(!B.saved||B.value)F[P]=B.value}ce={type:"local",command:L,environment:Object.keys(F).length?F:void 0,enabled:m?m.config.enabled:!0,defer:x==="default"?void 0:x,timeout:ne}}else{let L=z.trim();try{let P=new URL(L);if(P.protocol!=="http:"&&P.protocol!=="https:")throw Error("bad protocol")}catch{Q("请输入合法的 HTTP 或 HTTPS 地址");return}let F={};for(let P of U){let ae=P.key.trim();if(!ae)continue;if(!P.saved||P.value)F[ae]=P.value}let B;if(T){let P=C.trim(),ae=p.trim(),ue=D.trim();if(P||ae||ue)B={clientId:P||void 0,clientSecret:ae||void 0,scope:ue||void 0};else B=!0}else B=!1;ce={type:"remote",url:L,headers:Object.keys(F).length?F:void 0,oauth:B,enabled:m?m.config.enabled:!0,defer:x==="default"?void 0:x,timeout:ne}}pe(!0);try{let L=m?.name??w,F=m?m.projectID:e.projectID,B=F?`?projectID=${encodeURIComponent(F)}`:"";await e.connection.request(`/api/mcp/${encodeURIComponent(L)}${B}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(ce)}),e.onSaved()}catch(L){Q(L instanceof Error?L.message:"保存失败")}finally{pe(!1)}}return t(y,{open:!0,onOpenChange:(b)=>{if(!b&&!ie)e.onClose()},title:m?`编辑 ${m.name}`:"添加 MCP 服务器",size:"lg",footer:n("div",{className:"flex w-full justify-end gap-2.5",children:[t(d,{type:"button",variant:"ghost",onClick:e.onClose,disabled:ie,className:"min-w-20",children:"取消"}),t(d,{type:"submit",form:"mcp-server-form",variant:"primary",disabled:ie,className:"min-w-24",children:ie?"保存中...":"保存"})]}),children:n(N,{id:"mcp-server-form",onSubmit:Ie,children:[t(g,{value:q,onChange:(b)=>G(b),className:"w-full [&>button]:flex-1",options:[{value:"local",label:"本地(标准输入输出)"},{value:"remote",label:"远程(HTTP / SSE)"}]}),!m&&t(u,{label:"名称",aside:t(H,{children:"唯一标识,如 postgres"}),children:(b)=>t(c,{id:b,value:K,onChange:(w)=>S(w.target.value),placeholder:"postgres",className:"font-mono text-xs"})}),q==="local"?n(v,{children:[t(u,{label:"启动命令",aside:t(H,{children:"完整命令及参数"}),children:(b)=>t(c,{id:b,value:j,onChange:(w)=>W(w.target.value),placeholder:"npx -y @modelcontextprotocol/server-postgres ...",className:"font-mono text-xs"})}),t(ye,{label:"环境变量",tip:"启动进程时注入",keyLabel:"变量名",pairs:A,onChange:O,InputComponent:c})]}):n(v,{children:[t(u,{label:"服务地址",aside:t(H,{children:"HTTP / HTTPS 端点"}),children:(b)=>t(c,{id:b,value:z,onChange:(w)=>V(w.target.value),placeholder:"https://example.com/mcp",className:"font-mono text-xs"})}),t(ye,{label:"请求头",tip:"随每次请求发送",keyLabel:"头字段",pairs:U,onChange:Y,InputComponent:c}),n("div",{className:"flex items-center justify-between gap-4",children:[n("div",{className:"min-w-0",children:[t("span",{className:"block text-[13px] font-medium text-dim",children:"OAuth 2.0 认证"}),t("span",{className:"block truncate text-xs text-faint",children:"自动发现授权端点,使用 PKCE 并刷新令牌"})]}),t(k,{checked:T,onCheckedChange:r,label:"启用 OAuth 2.0"})]}),T&&n(v,{children:[t(u,{label:"Client ID",aside:t(H,{children:"留空自动动态注册(DCR)"}),children:(b)=>t(c,{id:b,value:C,onChange:(w)=>M(w.target.value),placeholder:"留空自动动态注册",className:"font-mono text-xs"})}),t(u,{label:"Client Secret",aside:t(H,{children:"留空保持不变"}),children:(b)=>t(c,{id:b,type:"password",autoComplete:"off",value:p,onChange:(w)=>f(w.target.value),placeholder:"••••••••",className:"font-mono text-xs"})}),t(u,{label:"Scope",aside:t(H,{children:"选填授权范围"}),children:(b)=>t(c,{id:b,value:D,onChange:(w)=>R(w.target.value),placeholder:"repo read:org",className:"font-mono text-xs"})})]})]}),n("div",{className:"space-y-3 border-t border-line/60 pt-3",children:[n("button",{type:"button","aria-expanded":se,className:"flex w-full cursor-pointer items-center gap-1.5 text-[13px] font-medium text-dim transition-colors hover:text-ink",onClick:()=>ke(!se),children:[t(yt,{className:`size-3.5 transition-transform ${se?"rotate-90":""}`}),"高级设置",t("span",{className:"truncate text-xs font-normal text-faint",children:"加载时机、超时"})]}),se&&n("div",{className:"grid grid-cols-2 gap-3 max-sm:grid-cols-1",children:[t(u,{label:"加载时机",aside:t(H,{children:"延迟 = 按需加载"}),children:()=>t(g,{value:x,onChange:(b)=>J(b),className:"w-full [&>button]:flex-1",options:[{value:"default",label:"默认"},{value:"defer",label:"延迟"},{value:"always",label:"常驻"}]})}),t(u,{label:"超时(毫秒)",aside:t(H,{children:"留空用默认"}),children:(b)=>t(c,{id:b,value:ee,onChange:(w)=>we(w.target.value),placeholder:"默认",className:"font-mono text-xs"})})]})]}),me&&n("div",{role:"alert",className:s("callout.base",s("callout.danger"),"px-3 py-2.5 text-xs"),children:[t(Z,{className:"mt-0.5 size-3.5 shrink-0"}),t("span",{className:"min-w-0 break-words",children:me})]})]})})}function tt({connection:e}){let{Button:d,Input:g,style:y,useTheme:N}=_();N();let[u,c]=a(""),[k,s]=a(),[I,m]=a(),[q,G]=a(!1),[K,S]=a(),[j,W]=a(!1),z=i(!1),[V,A]=a(),O=i(0),U=h(async()=>{let r=++O.current;G(!0);try{let C=await e.request("/api/mcp");if(r!==O.current)return;s(C),m(void 0)}catch(C){if(r===O.current)m(C instanceof Error?C.message:"读取失败")}finally{if(r===O.current)G(!1)}},[e]);o(()=>(U(),()=>{O.current++}),[U]);async function Y(r,C){if(z.current)return;z.current=!0,W(!0);let M=O.current;try{let p=r.projectID?`?projectID=${encodeURIComponent(r.projectID)}`:"",f=await e.request(`/api/mcp/${encodeURIComponent(r.name)}${p}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({...r.config,enabled:C})});if(M===O.current)s((D)=>D?.map((R)=>R.name===f.name&&R.projectID===f.projectID?f:R))}finally{z.current=!1,W(!1)}}let E=k?.filter((r)=>`${r.name} ${X(r.config)}`.toLowerCase().includes(u.trim().toLowerCase())),T=k?.find((r)=>r.name===K);return n("div",{className:"min-w-0 space-y-6",children:[n("section",{className:"min-w-0",children:[n("div",{className:"mb-2.5 flex flex-wrap items-end justify-between gap-3 px-0.5",children:[n("div",{className:"min-w-0 flex-1 basis-48",children:[t("h2",{className:y("settings.groupTitle"),children:"MCP 服务器"}),t("p",{className:y("settings.groupDesc"),children:"外部工具与数据源管理"})]}),n("div",{className:"flex gap-2",children:[t(d,{variant:"ghost",disabled:q,onClick:U,className:"h-9 px-2.5 text-xs",children:t(te,{className:`size-3.5 ${q?"animate-spin":""}`})}),n(d,{variant:"secondary",onClick:()=>A({}),className:"h-9 px-2.5 text-xs",children:[t(Re,{className:"size-3.5 mr-1"}),"添加服务器"]})]})]}),I&&n("div",{role:"alert",className:y("callout.base",y("callout.danger"),"mb-3 flex-wrap items-center justify-between"),children:[n("p",{className:"min-w-0 flex-1 break-words text-sm text-danger",children:["无法读取 MCP 服务器:",I]}),t(d,{disabled:q,onClick:U,children:"重试"})]}),n("div",{className:"relative mb-3 min-w-0",children:[t(de,{"aria-hidden":!0,className:"pointer-events-none absolute top-3 left-3 size-4 text-faint"}),t(g,{type:"search","aria-label":"搜索 MCP 服务器",placeholder:"搜索服务器",value:u,onChange:(r)=>c(r.target.value),className:"h-10 min-w-0 pl-9"})]}),t("div",{className:y("settings.groupBox"),children:!k?t("div",{role:"status","aria-label":"正在加载",className:"divide-y divide-line",children:[0,1,2].map((r)=>n("div",{className:"h-16 space-y-2 px-4 py-3",children:[t("div",{className:"h-3 w-24 animate-pulse rounded bg-raised"}),t("div",{className:"h-3 w-2/3 animate-pulse rounded bg-raised"})]},r))}):E?.length===0?t("p",{className:"p-4 text-sm text-dim",children:"没有匹配的 MCP 服务器"}):t("ul",{className:"divide-y divide-line",children:E?.map((r)=>{let C=r.config.enabled===!1,M=r.scope==="file";return n("li",{className:`flex min-w-0 items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-raised/40 ${C?"opacity-55":""}`,children:[n("button",{type:"button",className:"group flex min-h-12 min-w-0 flex-1 cursor-pointer items-center gap-3 py-1 text-left focus-visible:outline-2 focus-visible:outline-accent","aria-label":`查看 ${r.name}`,disabled:M,title:M?"来自项目的 .mcp.json,只读":void 0,onClick:()=>S(r.name),children:[t("span",{"aria-hidden":!0,className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-raised text-dim",children:r.config.type==="local"?t(ot,{className:"size-4"}):t(ve,{className:"size-4"})}),n("span",{className:"min-w-0 flex-1",children:[t("span",{className:"block truncate text-sm font-medium text-ink",title:r.name,children:r.name}),t("span",{className:"mt-0.5 block truncate font-mono text-xs text-dim",title:X(r.config),children:X(r.config)})]}),t("span",{className:y("control.badge","shrink-0 text-[11px] text-dim"),children:r.scope==="project"?"项目":r.scope==="file"?".mcp.json":"全局"}),t(he,{info:r})]}),t("span",{className:"relative flex size-10 shrink-0 items-center justify-center",children:!M&&t("input",{type:"checkbox","aria-label":`启用服务器 ${r.name}`,className:xe,disabled:j||q,checked:!C,onChange:(p)=>Y(r,p.target.checked)})})]},r.name)})})})]}),T&&!V&&t(be,{connection:e,info:T,onClose:()=>S(void 0),onEdit:()=>A({info:T}),onChanged:(r)=>r?s((C)=>C?.map((M)=>M.name===r.name?r:M)):U()},`${T.projectID}:${T.name}`),V&&t(Ce,{connection:e,existing:V.info,taken:(k??[]).map((r)=>r.name),onClose:()=>A(void 0),onSaved:()=>{A(void 0),U()}})]})}export{tt as McpSection};
|
|
1
|
+
import{h,o,i,a,v,t,n,_,l,Z,gt,yt,un,ve,Re,te,de,jt,ot,re,tn,oe}from"./chunk-4bzqrwr0.js";var Se=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],fe=l("key-round",Se);function ge(e){let d=[],g="",y,N=!1;for(let u=0;u<e.length;u++){let c=e[u];if(y)if(c===y)y=void 0;else if(c==="\\"&&y==='"'&&u+1<e.length)g+=e[++u];else g+=c;else if(c==='"'||c==="'")y=c,N=!0;else if(c==="\\"&&u+1<e.length)g+=e[++u],N=!0;else if(/\s/.test(c)){if(N||g)d.push(g);g="",N=!1}else g+=c,N=!0}if(N||g)d.push(g);return d}function le(e){return e.map((d)=>d===""||/[\s"'\\]/.test(d)?`"${d.replace(/(["\\])/g,"\\$1")}"`:d).join(" ")}var xe="size-4 cursor-pointer rounded border-line text-accent accent-accent focus-visible:outline-2 focus-visible:outline-accent",je={connected:{label:"已连接",dot:"bg-success"},idle:{label:"待连接",dot:"bg-faint"},disabled:{label:"已停用",dot:"bg-faint"},failed:{label:"连接失败",dot:"bg-danger"},needs_auth:{label:"需要认证",dot:"bg-warning"}};function X(e){return e.type==="local"?le(e.command):e.url}function he({info:e,tools:d=!1}){let g=je[e.status.status];return n("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs text-dim",children:[t("span",{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full ${g.dot}`}),t("span",{className:d?void 0:"hidden @md/panel:inline",children:g.label}),d&&e.status.status==="connected"&&n("span",{className:"text-faint",children:["· ",e.toolCount," 个工具"]})]})}function Te(e){if(typeof e!=="object"||e===null||!("type"in e))return"any";let d=e.type;if(typeof d==="string")return d;if(Array.isArray(d))return d.filter((g)=>typeof g==="string").join(" | ")||"any";return"any"}function be(e){let{Button:d,CopyButton:g,Dialog:y,StatusChip:N,confirm:u,style:c,useTheme:k}=_();k();let{info:s,connection:I}=e,[m,q]=a(),[G,K]=a(),[S,j]=a(!1),W=s.status.status==="connected",z=s.status.status==="needs_auth",V=s.status.status==="failed",A=s.config.type==="remote"&&Boolean(s.config.oauth);o(()=>{function p(x){if(x&&x!==s.name)return;let J=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"";I.request(`/api/mcp/${encodeURIComponent(s.name)}/connect${J}`,{method:"POST"}).then((ee)=>e.onChanged(ee)).catch(()=>{})}function f(x){if(x.data?.type==="mcp-oauth-success")p(x.data.name)}function D(x){if(x.key==="basalt-mcp-oauth-event"&&x.newValue)try{let J=JSON.parse(x.newValue);p(J.name)}catch(J){}}window.addEventListener("message",f),window.addEventListener("storage",D);let R;if("BroadcastChannel"in window)R=new BroadcastChannel("basalt-mcp-oauth"),R.onmessage=(x)=>{if(x.data?.type==="mcp-oauth-success")p(x.data.name)};return()=>{window.removeEventListener("message",f),window.removeEventListener("storage",D),R?.close()}},[I,s.name,s.projectID,e]),o(()=>{if(s.status.status!=="connected")return;let p=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"";I.request(`/api/mcp/${encodeURIComponent(s.name)}/tools${p}`).then((f)=>{if(Array.isArray(f))q(f),K(void 0)}).catch((f)=>{K(f instanceof Error?f.message:"获取工具失败")})},[I,s.name,s.projectID,s.status.status]);async function O(p){j(!0);try{let f=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"",D=await I.request(`/api/mcp/${encodeURIComponent(s.name)}/${p}${f}`,{method:"POST"});e.onChanged(D)}catch{}finally{j(!1)}}async function U(){j(!0);try{let p=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"",f=s.status.status==="needs_auth"?s.status.authorizationUrl:void 0;if(!f)f=(await I.request(`/api/mcp/${encodeURIComponent(s.name)}/oauth/authorize${p}`,{method:"POST"})).authorizationUrl;if(f)window.open(f,"_blank","width=600,height=700")}catch(p){K(p instanceof Error?p.message:"获取授权链接失败")}finally{j(!1)}}async function Y(){j(!0);try{let p=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"",f=await I.request(`/api/mcp/${encodeURIComponent(s.name)}/oauth/clear${p}`,{method:"POST"});e.onChanged(f)}finally{j(!1)}}async function E(){if(!await u({title:`删除 ${s.name}?`,description:"删除后将断开连接并不再向会话提供其工具。",action:"删除",danger:!0}))return;j(!0);try{let f=s.projectID?`?projectID=${encodeURIComponent(s.projectID)}`:"";await I.request(`/api/mcp/${encodeURIComponent(s.name)}${f}`,{method:"DELETE"}),e.onChanged(),e.onClose()}finally{j(!1)}}let T=s.config,r=X(T),C="error"in s.status?s.status.error:void 0,M=m?.length??s.toolCount??0;return t(y,{open:!0,className:"bg-panel shadow-float",onOpenChange:(p)=>{if(!p&&!S)e.onClose()},title:n("div",{className:"flex flex-wrap items-center gap-3",children:[t("div",{className:"flex size-8 items-center justify-center rounded-[10px] border border-accent/20 bg-accent-soft text-accent",children:T.type==="local"?t(ot,{className:"size-4"}):t(ve,{className:"size-4"})}),t("span",{className:"font-serif text-lg font-semibold tracking-tight text-ink",children:s.name}),W?t(N,{tone:"success",pulse:!0,children:"已连接"}):z?t(N,{tone:"warning",pulse:!0,children:"需要授权"}):V?t(N,{tone:"danger",children:"连接失败"}):s.status.status==="disabled"?t(N,{tone:"neutral",children:"已停用"}):t(N,{tone:"neutral",children:"未连接"})]}),description:n("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5 text-xs",children:[n("span",{className:"flex min-w-0 max-w-full items-center gap-1 rounded-lg border border-line bg-raised/60 py-0.5 pr-1 pl-2.5 font-mono text-[11.5px] text-ink",children:[t("span",{className:"min-w-0 truncate",title:r,children:r}),t(g,{text:r,label:"复制地址",size:"icon-xs",className:"shrink-0 text-dim hover:text-ink"})]}),t("span",{className:"rounded-lg border border-line px-2 py-1 text-[11px] leading-none text-dim",children:T.type==="local"?"本地命令":"远程 HTTP"}),A&&n("span",{className:c("control.badgeAccent","gap-1 rounded-lg border border-accent/25 px-2 py-1"),children:[t(jt,{className:"size-3"}),"OAuth 2.0"]})]}),size:"lg",footer:n("div",{className:"flex w-full items-center justify-between gap-2 max-sm:flex-col",children:[n("div",{className:"flex items-center gap-1 max-sm:w-full",children:[A&&t(d,{type:"button",variant:"ghost",onClick:Y,disabled:S,title:"清除已保存的 OAuth 凭据",children:"清除凭据"}),t(d,{type:"button",variant:"danger-ghost",size:"icon-sm","aria-label":"删除服务器",onClick:E,disabled:S,title:"删除服务器",children:t(re,{className:"size-4"})})]}),n("div",{className:"flex items-center gap-2 max-sm:w-full max-sm:justify-end",children:[t(d,{type:"button",variant:"ghost",onClick:e.onEdit,disabled:S,children:"编辑配置"}),!z&&t(d,{type:"button",variant:"secondary",onClick:()=>O(W?"disconnect":"connect"),disabled:S,children:S?"处理中...":W?"断开连接":"立即连接"}),t(d,{type:"button",variant:"primary",onClick:e.onClose,children:"完成"})]})]}),children:n("div",{className:"space-y-6 pt-1",children:[z&&t("div",{className:"relative overflow-hidden rounded-2xl border border-warning/30 bg-[radial-gradient(120%_140%_at_0%_0%,color-mix(in_oklch,var(--color-warning)_16%,transparent),transparent_65%)] p-5",children:n("div",{className:"flex items-start gap-4 max-sm:flex-col",children:[t("div",{className:"relative flex size-11 shrink-0 items-center justify-center rounded-xl border border-warning/30 bg-panel text-warning shadow-[0_0_28px_-4px_color-mix(in_oklch,var(--color-warning)_55%,transparent)]",children:t(fe,{className:"size-5"})}),n("div",{className:"min-w-0 flex-1 space-y-1.5",children:[t("h4",{className:"text-sm font-semibold text-ink",children:"授权后即可使用此服务器"}),t("p",{className:"text-[13px] leading-relaxed text-dim",children:"该端点要求 OAuth 2.0 身份许可。在浏览器中完成授权后,令牌会自动保存并载入全部工具。"}),C&&t("p",{className:"line-clamp-2 break-words font-mono text-[11.5px] text-faint",title:C,children:C})]}),n(d,{type:"button",variant:"primary",onClick:U,disabled:S,className:"shrink-0",children:[t(un,{className:"mr-1.5 size-3.5"}),S?"正在拉起授权...":"前往授权"]})]})}),V&&n("div",{className:c("callout.base",c("callout.danger"),"gap-3 rounded-2xl p-4"),children:[t(gt,{className:"mt-0.5 size-4 shrink-0 text-danger"}),n("div",{className:"min-w-0 space-y-1",children:[t("h4",{className:"text-sm font-medium text-ink",children:"连接失败"}),t("p",{className:"font-mono text-[11.5px] leading-relaxed break-words text-dim",children:C})]})]}),n("section",{className:"space-y-3",children:[n("div",{className:"flex items-baseline justify-between gap-3 px-0.5",children:[n("h4",{className:"flex items-center gap-2 text-[13px] font-medium text-ink",children:["可用工具",t("span",{className:"rounded-full bg-raised px-1.5 py-0.5 font-mono text-[11px] leading-none text-dim",children:M})]}),t("span",{className:"text-[11.5px] text-faint",children:"对所有会话可用"})]}),G?t("div",{className:c("callout.base",c("callout.danger"),"text-xs leading-relaxed break-words"),children:G}):!W?n("div",{className:c("surface.emptyDashed","gap-2 py-10"),children:[t("div",{className:"flex size-10 items-center justify-center rounded-full bg-raised text-faint",children:t(tn,{className:"size-4.5"})}),t("p",{className:"text-[13px] font-medium text-dim",children:z?"等待授权":"尚未连接"}),t("p",{className:"max-w-xs text-xs leading-relaxed text-faint",children:z?"授权完成后会自动连接并列出工具。":"连接服务器后,这里会列出它提供的全部工具。"})]}):!m?t("div",{role:"status","aria-label":"正在获取工具列表",className:"grid gap-2",children:[0,1,2].map((p)=>n("div",{className:"animate-pulse space-y-2.5 rounded-xl border border-line p-3.5",children:[t("div",{className:"h-3.5 w-32 rounded bg-raised"}),t("div",{className:"h-3 w-4/5 rounded bg-raised/70"})]},p))}):m.length===0?n("div",{className:c("surface.emptyDashed","gap-2 py-10"),children:[t("div",{className:"flex size-10 items-center justify-center rounded-full bg-raised text-faint",children:t(tn,{className:"size-4.5"})}),t("p",{className:"text-[13px] font-medium text-dim",children:"没有可用工具"}),t("p",{className:"max-w-xs text-xs leading-relaxed text-faint",children:"已连接成功,但该服务器没有声明任何工具。"})]}):t("ul",{className:"grid gap-2",children:m.map((p)=>{let f=p.inputSchema?.properties??{},D=p.inputSchema?.required??[],R=Object.entries(f);return n("li",{className:c("surface.subtle","border-line bg-raised/30 p-3.5 transition-colors hover:border-line-strong hover:bg-raised/60"),children:[t("span",{className:"font-mono text-[13px] font-medium break-all text-accent",children:p.name}),p.description&&t("p",{className:"mt-1.5 text-[13px] leading-relaxed break-words text-dim",children:p.description}),R.length>0&&t("div",{className:"mt-3 flex flex-wrap gap-1.5",children:R.map(([x,J])=>n("span",{title:D.includes(x)?"必填参数":"可选参数",className:"inline-flex items-center gap-1 rounded-md border border-line bg-panel px-1.5 py-1 font-mono text-[11px] leading-none",children:[t("span",{className:"text-ink",children:x}),D.includes(x)&&t("span",{className:"text-warning",children:"*"}),t("span",{className:"text-faint",children:Te(J)})]},x))})]},p.name)})})]})]})})}var $e=/^[A-Za-z0-9_-]{1,64}$/;function H(e){return t("span",{className:"truncate text-xs text-faint",children:e.children})}function ye(e){let{pairs:d,onChange:g,InputComponent:y}=e,N=(u,c)=>g(d.map((k,s)=>s===u?{...k,...c}:k));return n("div",{className:"space-y-2",children:[n("div",{className:"flex min-h-7 items-center gap-2",children:[t("span",{className:"shrink-0 text-[13px] font-medium text-dim",children:e.label}),t(H,{children:e.tip}),n("button",{type:"button",className:"ml-auto inline-flex h-7 shrink-0 cursor-pointer items-center gap-1 rounded-lg px-2 text-xs font-medium text-dim transition-colors hover:bg-raised hover:text-ink",onClick:()=>g([...d,{key:"",value:"",saved:!1}]),children:[t(Re,{className:"size-3.5"}),"添加"]})]}),d.map((u,c)=>n("div",{className:"flex min-w-0 items-center gap-1.5",children:[t(y,{"aria-label":`${e.keyLabel} ${c+1}`,placeholder:e.keyLabel,value:u.key,readOnly:u.saved,onChange:(k)=>N(c,{key:k.target.value}),className:"min-w-0 flex-[2] font-mono text-xs"}),t(y,{"aria-label":`${e.keyLabel} ${u.key||c+1} 的值`,type:"password",autoComplete:"off",placeholder:u.saved?"已保存,留空保持不变":"值",value:u.value,onChange:(k)=>N(c,{value:k.target.value}),className:"min-w-0 flex-[3] font-mono text-xs"}),t("button",{type:"button","aria-label":`删除 ${u.key||"该项"}`,className:"flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-faint transition-colors hover:bg-danger/10 hover:text-danger",onClick:()=>g(d.filter((k,s)=>s!==c)),children:t(oe,{className:"size-4"})})]},c))]})}function Ne(e){return Object.keys(e??{}).map((d)=>({key:d,value:"",saved:!0}))}function Ce(e){let{Button:d,Segmented:g,Dialog:y,Form:N,Field:u,Input:c,Switch:k,style:s,useTheme:I}=_();I();let{existing:m}=e,[q,G]=a(m?.config.type??"local"),[K,S]=a(m?.name??""),[j,W]=a(m?.config.type==="local"?le(m.config.command):""),[z,V]=a(m?.config.type==="remote"?m.config.url:""),[A,O]=a(Ne(m?.config.type==="local"?m.config.environment:void 0)),[U,Y]=a(Ne(m?.config.type==="remote"?m.config.headers:void 0)),E=m?.config.type==="remote"?m.config.oauth:void 0,[T,r]=a(Boolean(E)),[C,M]=a(typeof E==="object"&&E.clientId?E.clientId:""),[p,f]=a(""),[D,R]=a(typeof E==="object"&&E.scope?E.scope:""),[x,J]=a(m?.config.defer??"default"),[ee,we]=a(m?.config.timeout!==void 0?String(m.config.timeout):""),[se,ke]=a(m?.config.defer!==void 0||m?.config.timeout!==void 0),[me,Q]=a(),[ie,pe]=a(!1);async function Ie(b){b.preventDefault(),Q(void 0);let w=K.trim();if(!m&&!$e.test(w)){Q("名称只能包含英文字母、数字、下划线与中划线,长度 1-64");return}if(!m&&e.taken.includes(w)){Q("同名服务器已存在");return}let ne=ee.trim()?Number.parseInt(ee.trim(),10):void 0;if(ne!==void 0&&(!Number.isFinite(ne)||ne<=0)){Q("超时时间须为大于 0 的毫秒数");return}let ce;if(q==="local"){let L=ge(j.trim());if(!L.length){Q("请输入启动命令");return}let F={};for(let B of A){let P=B.key.trim();if(!P)continue;if(!B.saved||B.value)F[P]=B.value}ce={type:"local",command:L,environment:Object.keys(F).length?F:void 0,enabled:m?m.config.enabled:!0,defer:x==="default"?void 0:x,timeout:ne}}else{let L=z.trim();try{let P=new URL(L);if(P.protocol!=="http:"&&P.protocol!=="https:")throw Error("bad protocol")}catch{Q("请输入合法的 HTTP 或 HTTPS 地址");return}let F={};for(let P of U){let ae=P.key.trim();if(!ae)continue;if(!P.saved||P.value)F[ae]=P.value}let B;if(T){let P=C.trim(),ae=p.trim(),ue=D.trim();if(P||ae||ue)B={clientId:P||void 0,clientSecret:ae||void 0,scope:ue||void 0};else B=!0}else B=!1;ce={type:"remote",url:L,headers:Object.keys(F).length?F:void 0,oauth:B,enabled:m?m.config.enabled:!0,defer:x==="default"?void 0:x,timeout:ne}}pe(!0);try{let L=m?.name??w,F=m?m.projectID:e.projectID,B=F?`?projectID=${encodeURIComponent(F)}`:"";await e.connection.request(`/api/mcp/${encodeURIComponent(L)}${B}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(ce)}),e.onSaved()}catch(L){Q(L instanceof Error?L.message:"保存失败")}finally{pe(!1)}}return t(y,{open:!0,onOpenChange:(b)=>{if(!b&&!ie)e.onClose()},title:m?`编辑 ${m.name}`:"添加 MCP 服务器",size:"lg",footer:n("div",{className:"flex w-full justify-end gap-2.5",children:[t(d,{type:"button",variant:"ghost",onClick:e.onClose,disabled:ie,className:"min-w-20",children:"取消"}),t(d,{type:"submit",form:"mcp-server-form",variant:"primary",disabled:ie,className:"min-w-24",children:ie?"保存中...":"保存"})]}),children:n(N,{id:"mcp-server-form",onSubmit:Ie,children:[t(g,{value:q,onChange:(b)=>G(b),className:"w-full [&>button]:flex-1",options:[{value:"local",label:"本地(标准输入输出)"},{value:"remote",label:"远程(HTTP / SSE)"}]}),!m&&t(u,{label:"名称",aside:t(H,{children:"唯一标识,如 postgres"}),children:(b)=>t(c,{id:b,value:K,onChange:(w)=>S(w.target.value),placeholder:"postgres",className:"font-mono text-xs"})}),q==="local"?n(v,{children:[t(u,{label:"启动命令",aside:t(H,{children:"完整命令及参数"}),children:(b)=>t(c,{id:b,value:j,onChange:(w)=>W(w.target.value),placeholder:"npx -y @modelcontextprotocol/server-postgres ...",className:"font-mono text-xs"})}),t(ye,{label:"环境变量",tip:"启动进程时注入",keyLabel:"变量名",pairs:A,onChange:O,InputComponent:c})]}):n(v,{children:[t(u,{label:"服务地址",aside:t(H,{children:"HTTP / HTTPS 端点"}),children:(b)=>t(c,{id:b,value:z,onChange:(w)=>V(w.target.value),placeholder:"https://example.com/mcp",className:"font-mono text-xs"})}),t(ye,{label:"请求头",tip:"随每次请求发送",keyLabel:"头字段",pairs:U,onChange:Y,InputComponent:c}),n("div",{className:"flex items-center justify-between gap-4",children:[n("div",{className:"min-w-0",children:[t("span",{className:"block text-[13px] font-medium text-dim",children:"OAuth 2.0 认证"}),t("span",{className:"block truncate text-xs text-faint",children:"自动发现授权端点,使用 PKCE 并刷新令牌"})]}),t(k,{checked:T,onCheckedChange:r,label:"启用 OAuth 2.0"})]}),T&&n(v,{children:[t(u,{label:"Client ID",aside:t(H,{children:"留空自动动态注册(DCR)"}),children:(b)=>t(c,{id:b,value:C,onChange:(w)=>M(w.target.value),placeholder:"留空自动动态注册",className:"font-mono text-xs"})}),t(u,{label:"Client Secret",aside:t(H,{children:"留空保持不变"}),children:(b)=>t(c,{id:b,type:"password",autoComplete:"off",value:p,onChange:(w)=>f(w.target.value),placeholder:"••••••••",className:"font-mono text-xs"})}),t(u,{label:"Scope",aside:t(H,{children:"选填授权范围"}),children:(b)=>t(c,{id:b,value:D,onChange:(w)=>R(w.target.value),placeholder:"repo read:org",className:"font-mono text-xs"})})]})]}),n("div",{className:"space-y-3 border-t border-line/60 pt-3",children:[n("button",{type:"button","aria-expanded":se,className:"flex w-full cursor-pointer items-center gap-1.5 text-[13px] font-medium text-dim transition-colors hover:text-ink",onClick:()=>ke(!se),children:[t(yt,{className:`size-3.5 transition-transform ${se?"rotate-90":""}`}),"高级设置",t("span",{className:"truncate text-xs font-normal text-faint",children:"加载时机、超时"})]}),se&&n("div",{className:"grid grid-cols-2 gap-3 max-sm:grid-cols-1",children:[t(u,{label:"加载时机",aside:t(H,{children:"延迟 = 按需加载"}),children:()=>t(g,{value:x,onChange:(b)=>J(b),className:"w-full [&>button]:flex-1",options:[{value:"default",label:"默认"},{value:"defer",label:"延迟"},{value:"always",label:"常驻"}]})}),t(u,{label:"超时(毫秒)",aside:t(H,{children:"留空用默认"}),children:(b)=>t(c,{id:b,value:ee,onChange:(w)=>we(w.target.value),placeholder:"默认",className:"font-mono text-xs"})})]})]}),me&&n("div",{role:"alert",className:s("callout.base",s("callout.danger"),"px-3 py-2.5 text-xs"),children:[t(Z,{className:"mt-0.5 size-3.5 shrink-0"}),t("span",{className:"min-w-0 break-words",children:me})]})]})})}function tt({connection:e}){let{Button:d,Input:g,style:y,useTheme:N}=_();N();let[u,c]=a(""),[k,s]=a(),[I,m]=a(),[q,G]=a(!1),[K,S]=a(),[j,W]=a(!1),z=i(!1),[V,A]=a(),O=i(0),U=h(async()=>{let r=++O.current;G(!0);try{let C=await e.request("/api/mcp");if(r!==O.current)return;s(C),m(void 0)}catch(C){if(r===O.current)m(C instanceof Error?C.message:"读取失败")}finally{if(r===O.current)G(!1)}},[e]);o(()=>(U(),()=>{O.current++}),[U]);async function Y(r,C){if(z.current)return;z.current=!0,W(!0);let M=O.current;try{let p=r.projectID?`?projectID=${encodeURIComponent(r.projectID)}`:"",f=await e.request(`/api/mcp/${encodeURIComponent(r.name)}${p}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({...r.config,enabled:C})});if(M===O.current)s((D)=>D?.map((R)=>R.name===f.name&&R.projectID===f.projectID?f:R))}finally{z.current=!1,W(!1)}}let E=k?.filter((r)=>`${r.name} ${X(r.config)}`.toLowerCase().includes(u.trim().toLowerCase())),T=k?.find((r)=>r.name===K);return n("div",{className:"min-w-0 space-y-6",children:[n("section",{className:"min-w-0",children:[n("div",{className:"mb-2.5 flex flex-wrap items-end justify-between gap-3 px-0.5",children:[n("div",{className:"min-w-0 flex-1 basis-48",children:[t("h2",{className:y("settings.groupTitle"),children:"MCP 服务器"}),t("p",{className:y("settings.groupDesc"),children:"外部工具与数据源管理"})]}),n("div",{className:"flex gap-2",children:[t(d,{variant:"ghost",disabled:q,onClick:U,className:"h-9 px-2.5 text-xs",children:t(te,{className:`size-3.5 ${q?"animate-spin":""}`})}),n(d,{variant:"secondary",onClick:()=>A({}),className:"h-9 px-2.5 text-xs",children:[t(Re,{className:"size-3.5 mr-1"}),"添加服务器"]})]})]}),I&&n("div",{role:"alert",className:y("callout.base",y("callout.danger"),"mb-3 flex-wrap items-center justify-between"),children:[n("p",{className:"min-w-0 flex-1 break-words text-sm text-danger",children:["无法读取 MCP 服务器:",I]}),t(d,{disabled:q,onClick:U,children:"重试"})]}),n("div",{className:"relative mb-3 min-w-0",children:[t(de,{"aria-hidden":!0,className:"pointer-events-none absolute top-3 left-3 size-4 text-faint"}),t(g,{type:"search","aria-label":"搜索 MCP 服务器",placeholder:"搜索服务器",value:u,onChange:(r)=>c(r.target.value),className:"h-10 min-w-0 pl-9"})]}),t("div",{className:y("settings.groupBox"),children:!k?t("div",{role:"status","aria-label":"正在加载",className:"divide-y divide-line",children:[0,1,2].map((r)=>n("div",{className:"h-16 space-y-2 px-4 py-3",children:[t("div",{className:"h-3 w-24 animate-pulse rounded bg-raised"}),t("div",{className:"h-3 w-2/3 animate-pulse rounded bg-raised"})]},r))}):E?.length===0?t("p",{className:"p-4 text-sm text-dim",children:"没有匹配的 MCP 服务器"}):t("ul",{className:"divide-y divide-line",children:E?.map((r)=>{let C=r.config.enabled===!1,M=r.scope==="file";return n("li",{className:`flex min-w-0 items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-raised/40 ${C?"opacity-55":""}`,children:[n("button",{type:"button",className:"group flex min-h-12 min-w-0 flex-1 cursor-pointer items-center gap-3 py-1 text-left focus-visible:outline-2 focus-visible:outline-accent","aria-label":`查看 ${r.name}`,disabled:M,title:M?"来自项目的 .mcp.json,只读":void 0,onClick:()=>S(r.name),children:[t("span",{"aria-hidden":!0,className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-raised text-dim",children:r.config.type==="local"?t(ot,{className:"size-4"}):t(ve,{className:"size-4"})}),n("span",{className:"min-w-0 flex-1",children:[t("span",{className:"block truncate text-sm font-medium text-ink",title:r.name,children:r.name}),t("span",{className:"mt-0.5 block truncate font-mono text-xs text-dim",title:X(r.config),children:X(r.config)})]}),t("span",{className:y("control.badge","shrink-0 text-[11px] text-dim"),children:r.scope==="project"?"项目":r.scope==="file"?".mcp.json":"全局"}),t(he,{info:r})]}),t("span",{className:"relative flex size-10 shrink-0 items-center justify-center",children:!M&&t("input",{type:"checkbox","aria-label":`启用服务器 ${r.name}`,className:xe,disabled:j||q,checked:!C,onChange:(p)=>Y(r,p.target.checked)})})]},r.name)})})})]}),T&&!V&&t(be,{connection:e,info:T,onClose:()=>S(void 0),onEdit:()=>A({info:T}),onChanged:(r)=>r?s((C)=>C?.map((M)=>M.name===r.name?r:M)):U()},`${T.projectID}:${T.name}`),V&&t(Ce,{connection:e,existing:V.info,taken:(k??[]).map((r)=>r.name),onClose:()=>A(void 0),onSaved:()=>{A(void 0),U()}})]})}export{tt as McpSection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-wvdehm9y.js";import"./chunk-rvrf0f3h.js";import{ko}from"./chunk-hvw3gn2a.js";import"./chunk-0b47eyrf.js";import"./chunk-cjfssg3m.js";import"./chunk-bhsaj6qq.js";import"./chunk-p0kvmf28.js";export{ko as diagram};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,v,t,n,_,l,Z,ue,Jn}from"./chunk-
|
|
1
|
+
import{a,v,t,n,_,l,Z,ue,Jn}from"./chunk-4bzqrwr0.js";var u=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],s=l("code-xml",u);function Fr(e){let o=_();o.useTheme();let[m,c]=a("preview"),r=e.streaming&&!e.rendered,d=!e.streaming&&!e.rendered&&Boolean(e.error),i=m==="code"||r;return n(o.Panel,{"aria-label":e.title,"data-render-pending":e.pending&&!d?"true":void 0,className:"group/graph relative my-4 font-sans not-italic first:mt-0 last:mb-0",children:[t("div",{role:"toolbar","aria-label":`${e.title}操作`,className:r?"absolute top-2 right-2 z-10 flex items-center":o.style("surface.toolbarFloating","absolute top-2 right-2 z-10 opacity-0 transition-opacity duration-150 group-hover/graph:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-70"),children:r?n("span",{className:o.style("control.badge","gap-1.5 rounded-full px-2 py-0.5 text-[11px]"),children:[t(ue,{className:"size-3 animate-spin"}),"生成",e.title]}):n(v,{children:[t("button",{type:"button","aria-label":i?"查看图表":"查看代码",title:i?"查看图表":"查看代码",onClick:()=>c(i?"preview":"code"),className:"flex size-6 items-center justify-center rounded-md text-dim hover:bg-raised hover:text-ink [&_svg]:size-3.5",children:i?t(Jn,{}):t(s,{})}),t(o.CopyButton,{text:e.code,size:"icon-sm",label:"复制代码"})]})}),i&&t(o.Code,{code:e.code,lang:e.codeLang,className:"px-4 py-3"}),d&&!i&&n("div",{role:"alert",className:"flex flex-col items-center gap-2 px-4 py-8 text-center",children:[t(Z,{className:"size-5 text-warning"}),t("p",{className:"max-w-full text-xs break-words text-dim",children:e.error}),t("button",{type:"button",onClick:()=>c("code"),className:"text-xs text-accent-strong underline underline-offset-2",children:"查看代码"})]}),t("div",{hidden:i||d,children:e.children})]})}
|
|
2
2
|
export{Fr};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e,r,we,D,b,O,B,C,S,E,T,A,I,L,qn,V,U,qi}from"./chunk-
|
|
1
|
+
import{e,r,we,D,b,O,B,C,S,E,T,A,I,L,qn,V,U,qi}from"./chunk-wvdehm9y.js";import"./chunk-ds7srg4p.js";import{Xe}from"./chunk-n8sky2q6.js";import{xt}from"./chunk-kmr7r9xj.js";import{Mt}from"./chunk-cqp1d4p0.js";function Pt(t,i,s){t=+t,i=+i,s=(a=arguments.length)<2?(i=t,t=0,1):a<3?1:+s;var n=-1,a=Math.max(0,Math.ceil((i-t)/s))|0,c=Array(a);while(++n<a)c[n]=t+n*s;return c}function ft(){var t=Xe().unknown(void 0),{domain:i,range:s}=t,n=0,a=1,c,l,f=!1,g=0,y=0,z=0.5;delete t.unknown;function P(){var k=i().length,G=a<n,Y=G?a:n,N=G?n:a;if(c=(N-Y)/Math.max(1,k-g+y*2),f)c=Math.floor(c);if(Y+=(N-Y-c*(k-g))*z,l=c*(1-g),f)Y=Math.round(Y),l=Math.round(l);var j=Pt(k).map(function(it){return Y+c*it});return s(G?j.reverse():j)}return t.domain=function(k){return arguments.length?(i(k),P()):i()},t.range=function(k){return arguments.length?([n,a]=k,n=+n,a=+a,P()):[n,a]},t.rangeRound=function(k){return[n,a]=k,n=+n,a=+a,f=!0,P()},t.bandwidth=function(){return l},t.step=function(){return c},t.round=function(k){return arguments.length?(f=!!k,P()):f},t.padding=function(k){return arguments.length?(g=Math.min(1,y=+k),P()):g},t.paddingInner=function(k){return arguments.length?(g=Math.min(1,k),P()):g},t.paddingOuter=function(k){return arguments.length?(y=+k,P()):y},t.align=function(k){return arguments.length?(z=Math.max(0,Math.min(1,k)),P()):z},t.copy=function(){return ft(i(),[n,a]).round(f).paddingInner(g).paddingOuter(y).align(z)},Mt.apply(P(),arguments)}var Lt=function(){var t=e(function(J,h,u,x){for(u=u||{},x=J.length;x--;u[J[x]]=h);return u},"o"),i=[1,10,12,14,16,18,19,21,23],s=[2,6],n=[1,3],a=[1,5],c=[1,6],l=[1,7],f=[1,5,10,12,14,16,18,19,21,23,36,37,38],g=[1,25],y=[1,26],z=[1,28],P=[1,29],k=[1,30],G=[1,31],Y=[1,32],N=[1,33],j=[1,34],it=[1,35],nt=[1,36],R=[1,37],K=[1,43],d=[1,42],Q=[1,47],Z=[1,50],v=[1,10,12,14,16,18,19,21,23,36,37,38],ot=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],H=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],gt=[1,65],F=[26,28],_={trace:e(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:e(function(h,u,x,p,M,o,rt){var m=o.length-1;switch(M){case 5:p.setOrientation(o[m]);break;case 9:p.setDiagramTitle(o[m].text.trim());break;case 12:p.setLineData({text:"",type:"text"},o[m]);break;case 13:p.setLineData(o[m-1],o[m]);break;case 14:p.setBarData({text:"",type:"text"},o[m]);break;case 15:p.setBarData(o[m-1],o[m]);break;case 16:this.$=o[m].trim(),p.setAccTitle(this.$);break;case 17:case 18:this.$=o[m].trim(),p.setAccDescription(this.$);break;case 19:this.$=o[m-1];break;case 20:case 30:this.$=[o[m-2],...o[m]];break;case 21:case 31:this.$=[o[m]];break;case 22:this.$={value:Number(o[m-1]),label:o[m]};break;case 23:this.$={value:Number(o[m]),label:""};break;case 24:p.setXAxisTitle(o[m]);break;case 25:p.setXAxisTitle(o[m-1]);break;case 26:p.setXAxisTitle({type:"text",text:""});break;case 27:p.setXAxisBand(o[m]);break;case 28:p.setXAxisRangeData(Number(o[m-2]),Number(o[m]));break;case 29:this.$=o[m-1];break;case 32:p.setYAxisTitle(o[m]);break;case 33:p.setYAxisTitle(o[m-1]);break;case 34:p.setYAxisTitle({type:"text",text:""});break;case 35:p.setYAxisRangeData(Number(o[m-2]),Number(o[m]));break;case 39:this.$={text:o[m],type:"text"};break;case 40:this.$={text:o[m],type:"text"};break;case 41:this.$={text:o[m],type:"markdown"};break;case 42:this.$=o[m];break;case 43:this.$=o[m-1]+""+o[m];break}},"anonymous"),table:[t(i,s,{3:1,4:2,7:4,5:n,36:a,37:c,38:l}),{1:[3]},t(i,s,{4:2,7:4,3:8,5:n,36:a,37:c,38:l}),t(i,s,{4:2,7:4,6:9,3:10,5:n,8:[1,11],36:a,37:c,38:l}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},t(f,[2,36]),t(f,[2,37]),t(f,[2,38]),{1:[2,1]},t(i,s,{4:2,7:4,3:21,5:n,36:a,37:c,38:l}),{1:[2,3]},t(f,[2,5]),t(i,[2,7],{4:22,36:a,37:c,38:l}),{11:23,30:g,39:24,40:y,41:27,42:z,43:P,44:k,45:G,46:Y,47:N,48:j,49:it,50:nt,51:R},{11:39,13:38,24:K,29:d,30:g,31:40,32:41,39:24,40:y,41:27,42:z,43:P,44:k,45:G,46:Y,47:N,48:j,49:it,50:nt,51:R},{11:45,15:44,29:Q,30:g,35:46,39:24,40:y,41:27,42:z,43:P,44:k,45:G,46:Y,47:N,48:j,49:it,50:nt,51:R},{11:49,17:48,24:Z,30:g,39:24,40:y,41:27,42:z,43:P,44:k,45:G,46:Y,47:N,48:j,49:it,50:nt,51:R},{11:52,17:51,24:Z,30:g,39:24,40:y,41:27,42:z,43:P,44:k,45:G,46:Y,47:N,48:j,49:it,50:nt,51:R},{20:[1,53]},{22:[1,54]},t(v,[2,18]),{1:[2,2]},t(v,[2,8]),t(v,[2,9]),t(ot,[2,39],{41:55,42:z,43:P,44:k,45:G,46:Y,47:N,48:j,49:it,50:nt,51:R}),t(ot,[2,40]),t(ot,[2,41]),t(H,[2,42]),t(H,[2,44]),t(H,[2,45]),t(H,[2,46]),t(H,[2,47]),t(H,[2,48]),t(H,[2,49]),t(H,[2,50]),t(H,[2,51]),t(H,[2,52]),t(H,[2,53]),t(v,[2,10]),t(v,[2,24],{32:41,31:56,24:K,29:d}),t(v,[2,26]),t(v,[2,27]),{33:[1,57]},{11:59,30:g,34:58,39:24,40:y,41:27,42:z,43:P,44:k,45:G,46:Y,47:N,48:j,49:it,50:nt,51:R},t(v,[2,11]),t(v,[2,32],{35:60,29:Q}),t(v,[2,34]),{33:[1,61]},t(v,[2,12]),{17:62,24:Z},{25:63,27:64,29:gt},t(v,[2,14]),{17:66,24:Z},t(v,[2,16]),t(v,[2,17]),t(H,[2,43]),t(v,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},t(v,[2,33]),{29:[1,70]},t(v,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},t(F,[2,23],{30:[1,73]}),t(v,[2,15]),t(v,[2,28]),t(v,[2,29]),{11:59,30:g,34:74,39:24,40:y,41:27,42:z,43:P,44:k,45:G,46:Y,47:N,48:j,49:it,50:nt,51:R},t(v,[2,35]),t(v,[2,19]),{25:75,27:64,29:gt},t(F,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:e(function(h,u){if(u.recoverable)this.trace(h);else{var x=Error(h);throw x.hash=u,x}},"parseError"),parse:e(function(h){var u=this,x=[0],p=[],M=[null],o=[],rt=this.table,m="",yt=0,Ht=0,$t=0,fe=2,Ut=1,pe=o.slice.call(arguments,1),X=Object.create(this.lexer),ht={yy:{}};for(var Rt in this.yy)if(Object.prototype.hasOwnProperty.call(this.yy,Rt))ht.yy[Rt]=this.yy[Rt];if(X.setInput(h,ht.yy),ht.yy.lexer=X,ht.yy.parser=this,typeof X.yylloc>"u")X.yylloc={};var _t=X.yylloc;o.push(_t);var me=X.options&&X.options.ranges;if(typeof ht.yy.parseError==="function")this.parseError=ht.yy.parseError;else this.parseError=Object.getPrototypeOf(this).parseError;function be(et){x.length=x.length-2*et,M.length=M.length-et,o.length=o.length-et}e(be,"popStack");function qt(){var et=p.pop()||X.lex()||Ut;if(typeof et!=="number"){if(et instanceof Array)p=et,et=p.pop();et=u.symbols_[et]||et}return et}e(qt,"lex");var q,Tt,lt,tt,Oe,Dt,ut={},wt,at,Gt,kt;while(!0){if(lt=x[x.length-1],this.defaultActions[lt])tt=this.defaultActions[lt];else{if(q===null||typeof q>"u")q=qt();tt=rt[lt]&&rt[lt][q]}if(typeof tt>"u"||!tt.length||!tt[0]){var vt="";kt=[];for(wt in rt[lt])if(this.terminals_[wt]&&wt>fe)kt.push("'"+this.terminals_[wt]+"'");if(X.showPosition)vt="Parse error on line "+(yt+1)+`:
|
|
2
2
|
`+X.showPosition()+`
|
|
3
3
|
Expecting `+kt.join(", ")+", got '"+(this.terminals_[q]||q)+"'";else vt="Parse error on line "+(yt+1)+": Unexpected "+(q==Ut?"end of input":"'"+(this.terminals_[q]||q)+"'");this.parseError(vt,{text:X.match,token:this.terminals_[q]||q,line:X.yylineno,loc:_t,expected:kt})}if(tt[0]instanceof Array&&tt.length>1)throw Error("Parse Error: multiple actions possible at state: "+lt+", token: "+q);switch(tt[0]){case 1:if(x.push(q),M.push(X.yytext),o.push(X.yylloc),x.push(tt[1]),q=null,!Tt){if(Ht=X.yyleng,m=X.yytext,yt=X.yylineno,_t=X.yylloc,$t>0)$t--}else q=Tt,Tt=null;break;case 2:if(at=this.productions_[tt[1]][1],ut.$=M[M.length-at],ut._$={first_line:o[o.length-(at||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(at||1)].first_column,last_column:o[o.length-1].last_column},me)ut._$.range=[o[o.length-(at||1)].range[0],o[o.length-1].range[1]];if(Dt=this.performAction.apply(ut,[m,Ht,yt,ht.yy,tt[1],M,o].concat(pe)),typeof Dt<"u")return Dt;if(at)x=x.slice(0,-1*at*2),M=M.slice(0,-1*at),o=o.slice(0,-1*at);x.push(this.productions_[tt[1]][0]),M.push(ut.$),o.push(ut._$),Gt=rt[x[x.length-2]][x[x.length-1]],x.push(Gt);break;case 3:return!0}}return!0},"parse")},st=function(){var J={EOF:1,parseError:e(function(u,x){if(this.yy.parser)this.yy.parser.parseError(u,x);else throw Error(u)},"parseError"),setInput:e(function(h,u){if(this.yy=u||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:e(function(){var h=this._input[0];this.yytext+=h,this.yyleng++,this.offset++,this.match+=h,this.matched+=h;var u=h.match(/(?:\r\n?|\n).*/g);if(u)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:e(function(h){var u=h.length,x=h.split(/(?:\r\n?|\n)/g);this._input=h+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-u),this.offset-=u;var p=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),x.length-1)this.yylineno-=x.length-1;var M=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:x?(x.length===p.length?this.yylloc.first_column:0)+p[p.length-x.length].length-x[0].length:this.yylloc.first_column-u},this.options.ranges)this.yylloc.range=[M[0],M[0]+this.yyleng-u];return this.yyleng=this.yytext.length,this},"unput"),more:e(function(){return this._more=!0,this},"more"),reject:e(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:e(function(h){this.unput(this.match.slice(h))},"less"),pastInput:e(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:e(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:e(function(){var h=this.pastInput(),u=Array(h.length+1).join("-");return h+this.upcomingInput()+`
|