@cuongtran001/kanna 0.103.2 → 0.104.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +22 -9
  2. package/dist/client/assets/{arc-CCUkD8tQ.js → arc-De_iw4Y1.js} +1 -1
  3. package/dist/client/assets/{architectureDiagram-3BPJPVTR-CfxSaVWT.js → architectureDiagram-3BPJPVTR-DV3RZxWy.js} +1 -1
  4. package/dist/client/assets/{blockDiagram-GPEHLZMM-D7j7-Fa4.js → blockDiagram-GPEHLZMM-BEeZSTpn.js} +1 -1
  5. package/dist/client/assets/{c4Diagram-AAUBKEIU-TCdSaNjq.js → c4Diagram-AAUBKEIU-C0VVj-H4.js} +1 -1
  6. package/dist/client/assets/channel-ByuZlsoo.js +1 -0
  7. package/dist/client/assets/{chunk-2J33WTMH-CgTAWat8.js → chunk-2J33WTMH-CS4MJByB.js} +1 -1
  8. package/dist/client/assets/{chunk-4BX2VUAB-DfxZAfFN.js → chunk-4BX2VUAB-aarezXOb.js} +1 -1
  9. package/dist/client/assets/{chunk-55IACEB6-Cnbje1wh.js → chunk-55IACEB6-Dtr41Bbh.js} +1 -1
  10. package/dist/client/assets/{chunk-727SXJPM-So6j2UlN.js → chunk-727SXJPM-DZOBbpW3.js} +1 -1
  11. package/dist/client/assets/{chunk-AQP2D5EJ-CzJY3yT5.js → chunk-AQP2D5EJ-Bu_RRmqy.js} +1 -1
  12. package/dist/client/assets/{chunk-FMBD7UC4-D5M-wG3V.js → chunk-FMBD7UC4-DgWKhHkD.js} +1 -1
  13. package/dist/client/assets/{chunk-ND2GUHAM-BZUoPqVa.js → chunk-ND2GUHAM-D4ymxCV8.js} +1 -1
  14. package/dist/client/assets/{chunk-QZHKN3VN-Cy43IOZj.js → chunk-QZHKN3VN-BSfOsOcT.js} +1 -1
  15. package/dist/client/assets/classDiagram-4FO5ZUOK-CSVd5I3j.js +1 -0
  16. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CSVd5I3j.js +1 -0
  17. package/dist/client/assets/{cose-bilkent-S5V4N54A-CmuAF61a.js → cose-bilkent-S5V4N54A-DUax6WYY.js} +1 -1
  18. package/dist/client/assets/{dagre-BM42HDAG-C5zqZwAd.js → dagre-BM42HDAG-DXooVaxB.js} +1 -1
  19. package/dist/client/assets/{diagram-2AECGRRQ-bVCq4X3Y.js → diagram-2AECGRRQ-O_qyDE6S.js} +1 -1
  20. package/dist/client/assets/{diagram-5GNKFQAL-C8ZqAC77.js → diagram-5GNKFQAL-BbevjuHs.js} +1 -1
  21. package/dist/client/assets/{diagram-KO2AKTUF-Cq-3WGm9.js → diagram-KO2AKTUF-BzHzIpTF.js} +1 -1
  22. package/dist/client/assets/{diagram-LMA3HP47-Dh22vV_F.js → diagram-LMA3HP47-BgDWr9mM.js} +1 -1
  23. package/dist/client/assets/{diagram-OG6HWLK6-CtknilES.js → diagram-OG6HWLK6-Gz0sTj8F.js} +1 -1
  24. package/dist/client/assets/{erDiagram-TEJ5UH35-C6IjLjaq.js → erDiagram-TEJ5UH35-PutPNGSX.js} +1 -1
  25. package/dist/client/assets/{flowDiagram-I6XJVG4X-00r4-GOq.js → flowDiagram-I6XJVG4X-CNwMFwBk.js} +1 -1
  26. package/dist/client/assets/{ganttDiagram-6RSMTGT7--YxeaVBU.js → ganttDiagram-6RSMTGT7-Dq2MNFcV.js} +1 -1
  27. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-tzi-v_MK.js → gitGraphDiagram-PVQCEYII-GNoLlTjo.js} +1 -1
  28. package/dist/client/assets/{index-BR50BDgo.js → index-B2ffbfmL.js} +1 -1
  29. package/dist/client/assets/index-DJgQSfhz.css +32 -0
  30. package/dist/client/assets/{index-gCnSa5WG.js → index-Djru1Edw.js} +255 -245
  31. package/dist/client/assets/{infoDiagram-5YYISTIA-CHik8wWu.js → infoDiagram-5YYISTIA-C_7n-IaH.js} +1 -1
  32. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH--iNw5yIu.js → ishikawaDiagram-YF4QCWOH-gIoMaD7o.js} +1 -1
  33. package/dist/client/assets/{journeyDiagram-JHISSGLW-DpLGJlZo.js → journeyDiagram-JHISSGLW-gMkJmdEu.js} +1 -1
  34. package/dist/client/assets/{kanban-definition-UN3LZRKU-B0lUJECW.js → kanban-definition-UN3LZRKU-Dv75kEt8.js} +1 -1
  35. package/dist/client/assets/{linear-BMtLb8uL.js → linear-BFkXbMjH.js} +1 -1
  36. package/dist/client/assets/{mermaid.core-DZC2xPj2.js → mermaid.core-DUUbMNR2.js} +4 -4
  37. package/dist/client/assets/{mindmap-definition-RKZ34NQL-BXmE_sWG.js → mindmap-definition-RKZ34NQL-l1F3qpf-.js} +1 -1
  38. package/dist/client/assets/{pieDiagram-4H26LBE5-B0yOSA3G.js → pieDiagram-4H26LBE5-xlqill1b.js} +1 -1
  39. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-CtKlgtcX.js → quadrantDiagram-W4KKPZXB-BYf_yy4k.js} +1 -1
  40. package/dist/client/assets/{requirementDiagram-4Y6WPE33-Bk7HSQuK.js → requirementDiagram-4Y6WPE33-Bsb3qe8F.js} +1 -1
  41. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-GmjfstgC.js → sankeyDiagram-5OEKKPKP-B5O11fEx.js} +1 -1
  42. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-tIeBICjU.js → sequenceDiagram-3UESZ5HK-BaVgC1yq.js} +1 -1
  43. package/dist/client/assets/{stateDiagram-AJRCARHV-Clpc3Yrj.js → stateDiagram-AJRCARHV-CIJX_VYo.js} +1 -1
  44. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-CjMQq7r5.js +1 -0
  45. package/dist/client/assets/{timeline-definition-PNZ67QCA-Bu1KJ7Dn.js → timeline-definition-PNZ67QCA-CI1XlBLf.js} +1 -1
  46. package/dist/client/assets/{vennDiagram-CIIHVFJN-aaFziJLh.js → vennDiagram-CIIHVFJN-BIV7nnU-.js} +1 -1
  47. package/dist/client/assets/{wardley-L42UT6IY-BSZVjFLo.js → wardley-L42UT6IY-BXH7o-2S.js} +1 -1
  48. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-B6leUMb-.js → wardleyDiagram-YWT4CUSO-CpY61KvS.js} +1 -1
  49. package/dist/client/assets/{xychartDiagram-2RQKCTM6-DdRKV_GL.js → xychartDiagram-2RQKCTM6-DV1YU2GI.js} +1 -1
  50. package/dist/client/index.html +2 -2
  51. package/package.json +1 -1
  52. package/src/server/agent.sdk-workflow-register.test.ts +10 -0
  53. package/src/server/agent.test.ts +1 -0
  54. package/src/server/agent.ts +2 -1
  55. package/src/server/server.ts +2 -0
  56. package/src/server/workflow-agent-transcript-io.adapter.test.ts +50 -0
  57. package/src/server/workflow-agent-transcript-io.adapter.ts +35 -0
  58. package/src/server/workflow-registry.test.ts +54 -0
  59. package/src/server/workflow-registry.ts +38 -0
  60. package/src/server/ws-router.ts +5 -0
  61. package/src/shared/protocol.ts +1 -0
  62. package/src/shared/workflow-types.test.ts +5 -1
  63. package/src/shared/workflow-types.ts +8 -2
  64. package/dist/client/assets/channel-Cq2MObYL.js +0 -1
  65. package/dist/client/assets/classDiagram-4FO5ZUOK-D-nzuIgE.js +0 -1
  66. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-D-nzuIgE.js +0 -1
  67. package/dist/client/assets/index-CPGRD5dt.css +0 -32
  68. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-yjxNiaH8.js +0 -1
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <em>Community fork of <a href="https://github.com/jakemor/kanna">jakemor/kanna</a> — kept in sync with upstream and extended with subscription-billing PTY mode, OAuth token pooling, multi-provider chat (Claude + Codex), subagent orchestration, durable tool-approval protocol, in-app self-update, and more.</em>
12
+ <em>Community fork of <a href="https://github.com/jakemor/kanna">jakemor/kanna</a> — kept in sync with upstream and extended with subscription-billing PTY mode, OAuth token pooling, multi-provider chat (Claude + Codex + OpenRouter), subagent orchestration, custom MCP servers, a workflow status panel, durable tool-approval protocol, in-app self-update, and more.</em>
13
13
  </p>
14
14
 
15
15
  <p align="center">
@@ -41,14 +41,17 @@ Kanna started life as [jakemor/kanna](https://github.com/jakemor/kanna) — a cl
41
41
 
42
42
  **Headline additions vs. upstream:**
43
43
 
44
- - **Subscription-billing PTY driver** (`KANNA_CLAUDE_DRIVER=pty`) — runs the `claude` CLI under a pseudo-terminal so Pro/Max plans are charged instead of API rates. Includes JSONL event parity with the SDK driver, macOS `sandbox-exec` / Linux `bwrap` sandboxing, allowlist preflight probes, and failure-mode parity.
44
+ - **Subscription-billing PTY driver** (`KANNA_CLAUDE_DRIVER=pty`) — runs the `claude` CLI under a pseudo-terminal so Pro/Max plans are charged instead of API rates. Parses the on-disk transcript JSONL as the sole event source, with HarnessEvent parity with the SDK driver, a cached per-spawn smoke-test gate, and failure-mode parity.
45
45
  - **OAuth token pool** — register multiple Claude OAuth tokens; Kanna rotates across them per chat with automatic fallover on rate-limit and an explicit disabled state.
46
- - **Multi-provider chat** — switch between Claude and Codex (OpenAI) from the composer with per-provider model + reasoning-effort controls and Codex fast mode.
47
- - **Subagent orchestration** — first-class subagent CRUD, `@agent/` mentions, parallel runs, live activity labels, MCP progress notifications, and `mcp__kanna__delegate_subagent` so the main agent itself can delegate.
46
+ - **Multi-provider chat** — switch between Claude, Codex (OpenAI), and OpenRouter from the composer with per-provider model + reasoning-effort controls and Codex fast mode. OpenRouter populates its model picker live from the public catalog (tool-capable models).
47
+ - **Subagent orchestration** — first-class subagent CRUD, `@agent/` mentions, parallel runs, live activity labels, MCP progress notifications, and `mcp__kanna__delegate_subagent` so the main agent itself can delegate — including **keep-alive multi-turn** sessions (`send_subagent_message` / `close_subagent`) and **background** runs that report back as a fresh turn.
48
+ - **Custom MCP servers** — register your own `stdio` / `http` / `sse` / `ws` MCP servers from Settings (with OAuth 2.1 for network transports); they merge into both drivers and their tools surface as `mcp__<name>__<tool>`.
49
+ - **Workflow status panel** — read-only per-chat panel surfacing Claude Code's native Workflow tool runs (live status, drill-in progress, token totals) via disk-watch, under both drivers.
50
+ - **Agent self-scheduled wake** — `mcp__kanna__schedule_wakeup` lets the agent re-enter the chat to harvest long-running background work, with a runaway-loop cap.
48
51
  - **Durable tool-approval protocol** (`KANNA_MCP_TOOL_CALLBACKS=1`) — pending `AskUserQuestion` / `ExitPlanMode` / built-in shims survive server restart and replay to the client on reconnect.
49
52
  - **Cloudflare `expose_port` MCP tool** — agent-callable port exposure with always-ask or auto-expose modes, replacing bash-output sniffing.
50
53
  - **In-app self-update** — one-click pull/rebuild/reload with a host-agnostic supervisor (works under pm2, systemd, docker, plain shell) or direct pm2 reload; install any prior release straight from the changelog UI.
51
- - **Git worktree isolation** per chat, **bulk import** of existing `~/.claude/projects/` sessions, **proactive context compaction**, **password gate** for HTTP/WS/API, **PWA / mobile layout**, **mermaid rendering** in transcripts, **standalone HTML transcript export**, and **customizable keybindings**.
54
+ - **Git worktree isolation** per chat, **bulk import** of existing `~/.claude/projects/` sessions, **proactive context compaction**, **per-turn token cost**, **local skills & slash commands** in the composer `/` picker, **password gate** for HTTP/WS/API, **PWA / mobile layout**, **mermaid rendering** in transcripts, **standalone HTML transcript export**, and **customizable keybindings**.
52
55
 
53
56
  See the full inventory in [Features](#features) below.
54
57
 
@@ -76,9 +79,11 @@ That's it. Kanna opens in your browser at [`localhost:3210`](http://localhost:32
76
79
 
77
80
  **Providers & models**
78
81
 
79
- - **Multi-provider support** — switch between Claude and Codex (OpenAI) from the chat input, with per-provider model selection, reasoning-effort controls, and Codex fast mode
82
+ - **Multi-provider support** — switch between Claude, Codex (OpenAI), and OpenRouter from the chat input, with per-provider model selection, reasoning-effort controls, and Codex fast mode
83
+ - **OpenRouter** — set an OpenRouter API key in Settings; the model picker populates live from OpenRouter's catalog (tool-capable models), routed through its Anthropic-compatible endpoint
80
84
  - **OAuth token pool** — register multiple Claude OAuth tokens; Kanna rotates across them per chat
81
85
  - **Subscription-billing PTY driver** — optional `KANNA_CLAUDE_DRIVER=pty` runs the `claude` CLI under a pseudo-terminal so Pro/Max subscription billing is preserved instead of API rates
86
+ - **Custom MCP servers** — register `stdio` / `http` / `sse` / `ws` MCP servers from Settings (OAuth 2.1 for network transports); merged into both drivers
82
87
 
83
88
  **Chat & transcript**
84
89
 
@@ -86,10 +91,13 @@ That's it. Kanna opens in your browser at [`localhost:3210`](http://localhost:32
86
91
  - **Inline diff viewer** — file and commit diffs rendered directly in the transcript
87
92
  - **Embedded terminal** — per-project xterm terminal in a resizable side panel (macOS/Linux)
88
93
  - **File & image uploads** — drag-and-drop attachments into the composer
89
- - **Slash commands & @-mentions** — in-composer pickers for slash commands, file mentions, and subagents
94
+ - **Slash commands & @-mentions** — in-composer pickers for slash commands (including local Claude Code skills/commands), file mentions, and subagents
90
95
  - **Plan mode** — review and approve agent plans before execution
91
- - **Subagent orchestration** — run and track parallel subagents within a turn
96
+ - **Subagent orchestration** — run and track parallel subagents within a turn, plus keep-alive multi-turn sessions and non-blocking background runs that report back as a fresh turn
97
+ - **Workflow status panel** — read-only per-chat view of Claude Code's native Workflow tool runs with live status and drill-in progress
98
+ - **Agent self-scheduled wake** — the agent can re-enter the chat to harvest long-running background work (`schedule_wakeup`), with a runaway-loop cap
92
99
  - **Background tasks** — long-running tasks tracked out-of-band with a status indicator
100
+ - **Per-turn token cost** — token usage and estimated USD cost shown inline per turn
93
101
  - **Auto-continue** — optionally continue a turn automatically when the agent stops short
94
102
  - **Proactive compaction** — context-window meter with automatic transcript compaction before limits are hit
95
103
 
@@ -390,22 +398,26 @@ src/
390
398
  │ ├── claude-pty/ PTY driver (subscription billing)
391
399
  │ ├── oauth-pool/ Claude OAuth token rotation
392
400
  │ ├── provider-catalog.ts provider/model/effort normalization
401
+ │ ├── openrouter-models.ts live OpenRouter catalog (tool-capable models)
393
402
  │ ├── quick-response.ts structured queries w/ provider fallback
394
403
  │ ├── event-store.ts JSONL persistence, replay & compaction
395
404
  │ ├── read-models.ts derived view models
396
405
  │ ├── events.ts event type definitions
397
406
  │ ├── discovery.ts auto-discover Claude/Codex projects
407
+ │ ├── local-catalog.ts local Claude skills/slash-command discovery
398
408
  │ ├── claude-session-importer.ts bulk import existing sessions
399
409
  │ ├── diff-store.ts per-chat diff hydration
400
410
  │ ├── terminal-manager.ts embedded-terminal PTY sessions
401
411
  │ ├── uploads.ts attachment intake
402
- │ ├── subagent-orchestrator.ts parallel subagent runs
412
+ │ ├── subagent-orchestrator.ts parallel + keep-alive + background subagent runs
413
+ │ ├── workflow-registry.ts workflow status panel (disk-watch read-model)
403
414
  │ ├── background-tasks.ts out-of-band task tracking
404
415
  │ ├── worktree-store.ts git worktree isolation
405
416
  │ ├── push/ web-push notifications
406
417
  │ ├── share.ts · cloudflare-tunnel/ trycloudflare / expose_port tunnels
407
418
  │ ├── update-manager.ts · update-strategy.ts self-update
408
419
  │ ├── kanna-mcp.ts Kanna MCP tools (built-in shims)
420
+ │ ├── mcp-validator.ts · mcp-oauth.adapter.ts custom MCP connect-test + OAuth
409
421
  │ └── keybindings.ts persisted keybindings
410
422
  └── shared/ Shared between client & server
411
423
  ├── types.ts core domain types, provider catalog, transcript entries
@@ -413,6 +425,7 @@ src/
413
425
  ├── protocol.ts WebSocket wire envelopes
414
426
  ├── ports.ts default ports & dev-mode offsets
415
427
  ├── share.ts share/tunnel shared types
428
+ ├── token-pricing.ts per-turn token cost (USD)
416
429
  └── branding.ts app name & data-directory paths
417
430
  ```
418
431
 
@@ -1 +1 @@
1
- import{M as ln,N as an,O as Y,P as O,Q,R as un,S as y,T as tn,V as j,W as _,X as rn,Y as o,Z as on,$ as sn,a0 as fn}from"./mermaid.core-DZC2xPj2.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,D,S,v,R,V,a){var E=D-l,i=S-h,n=V-v,d=a-R,u=d*E-n*i;if(!(u*u<y))return u=(n*(h-R)-d*(l-v))/u,[l+u*E,h+u*i]}function H(l,h,D,S,v,R,V){var a=l-D,E=h-S,i=(V?R:-R)/j(a*a+E*E),n=i*E,d=-i*a,u=l+n,s=h+d,f=D+n,c=S+d,W=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,A=m*m+g*g,T=v-R,P=u*c-f*s,I=(g<0?-1:1)*j(on(0,T*T*A-P*P)),M=(P*g-m*I)/A,N=(-P*m-g*I)/A,w=(P*g+m*I)/A,p=(-P*m+g*I)/A,x=M-W,e=N-t,r=w-W,X=p-t;return x*x+e*e>r*r+X*X&&(M=w,N=p),{cx:M,cy:N,x01:-n,y01:-d,x11:M*(v/T-1),y11:N*(v/T-1)}}function hn(){var l=cn,h=yn,D=Q(0),S=null,v=gn,R=dn,V=mn,a=null,E=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=R.apply(this,arguments)-un,W=rn(c-f),t=c>f;if(a||(a=n=E()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(W>tn-y)a.moveTo(s*Y(f),s*O(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*Y(c),u*O(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,A=f,T=c,P=W,I=W,M=V.apply(this,arguments)/2,N=M>y&&(S?+S.apply(this,arguments):j(u*u+s*s)),w=_(rn(s-u)/2,+D.apply(this,arguments)),p=w,x=w,e,r;if(N>y){var X=sn(N/u*O(M)),z=sn(N/s*O(M));(P-=X*2)>y?(X*=t?1:-1,A+=X,T-=X):(P=0,A=T=(f+c)/2),(I-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(I=0,m=g=(f+c)/2)}var Z=s*Y(m),$=s*O(m),B=u*Y(T),C=u*O(T);if(w>y){var F=s*Y(g),G=s*O(g),J=u*Y(A),K=u*O(A),q;if(W<an)if(q=pn(Z,$,J,K,F,G,B,C)){var L=Z-q[0],U=$-q[1],k=F-q[0],b=G-q[1],nn=1/O(fn((L*k+U*b)/(j(L*L+U*U)*j(k*k+b*b)))/2),en=j(q[0]*q[0]+q[1]*q[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}I>y?x>y?(e=H(J,K,Z,$,s,x,t),r=H(F,G,B,C,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(Z,$),a.arc(0,0,s,m,g,!t)):a.moveTo(Z,$),!(u>y)||!(P>y)?a.lineTo(B,C):p>y?(e=H(B,C,F,G,u,-p,t),r=H(Z,$,J,K,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,A,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-an/2;return[Y(d)*n,O(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:Q(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:Q(+n),i):h},i.cornerRadius=function(n){return arguments.length?(D=typeof n=="function"?n:Q(+n),i):D},i.padRadius=function(n){return arguments.length?(S=n==null?null:typeof n=="function"?n:Q(+n),i):S},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:Q(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:Q(+n),i):R},i.padAngle=function(n){return arguments.length?(V=typeof n=="function"?n:Q(+n),i):V},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{M as ln,N as an,O as Y,P as O,Q,R as un,S as y,T as tn,V as j,W as _,X as rn,Y as o,Z as on,$ as sn,a0 as fn}from"./mermaid.core-DUUbMNR2.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,D,S,v,R,V,a){var E=D-l,i=S-h,n=V-v,d=a-R,u=d*E-n*i;if(!(u*u<y))return u=(n*(h-R)-d*(l-v))/u,[l+u*E,h+u*i]}function H(l,h,D,S,v,R,V){var a=l-D,E=h-S,i=(V?R:-R)/j(a*a+E*E),n=i*E,d=-i*a,u=l+n,s=h+d,f=D+n,c=S+d,W=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,A=m*m+g*g,T=v-R,P=u*c-f*s,I=(g<0?-1:1)*j(on(0,T*T*A-P*P)),M=(P*g-m*I)/A,N=(-P*m-g*I)/A,w=(P*g+m*I)/A,p=(-P*m+g*I)/A,x=M-W,e=N-t,r=w-W,X=p-t;return x*x+e*e>r*r+X*X&&(M=w,N=p),{cx:M,cy:N,x01:-n,y01:-d,x11:M*(v/T-1),y11:N*(v/T-1)}}function hn(){var l=cn,h=yn,D=Q(0),S=null,v=gn,R=dn,V=mn,a=null,E=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=R.apply(this,arguments)-un,W=rn(c-f),t=c>f;if(a||(a=n=E()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(W>tn-y)a.moveTo(s*Y(f),s*O(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*Y(c),u*O(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,A=f,T=c,P=W,I=W,M=V.apply(this,arguments)/2,N=M>y&&(S?+S.apply(this,arguments):j(u*u+s*s)),w=_(rn(s-u)/2,+D.apply(this,arguments)),p=w,x=w,e,r;if(N>y){var X=sn(N/u*O(M)),z=sn(N/s*O(M));(P-=X*2)>y?(X*=t?1:-1,A+=X,T-=X):(P=0,A=T=(f+c)/2),(I-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(I=0,m=g=(f+c)/2)}var Z=s*Y(m),$=s*O(m),B=u*Y(T),C=u*O(T);if(w>y){var F=s*Y(g),G=s*O(g),J=u*Y(A),K=u*O(A),q;if(W<an)if(q=pn(Z,$,J,K,F,G,B,C)){var L=Z-q[0],U=$-q[1],k=F-q[0],b=G-q[1],nn=1/O(fn((L*k+U*b)/(j(L*L+U*U)*j(k*k+b*b)))/2),en=j(q[0]*q[0]+q[1]*q[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}I>y?x>y?(e=H(J,K,Z,$,s,x,t),r=H(F,G,B,C,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(Z,$),a.arc(0,0,s,m,g,!t)):a.moveTo(Z,$),!(u>y)||!(P>y)?a.lineTo(B,C):p>y?(e=H(B,C,F,G,u,-p,t),r=H(Z,$,J,K,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,A,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-an/2;return[Y(d)*n,O(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:Q(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:Q(+n),i):h},i.cornerRadius=function(n){return arguments.length?(D=typeof n=="function"?n:Q(+n),i):D},i.padRadius=function(n){return arguments.length?(S=n==null?null:typeof n=="function"?n:Q(+n),i):S},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:Q(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:Q(+n),i):R},i.padAngle=function(n){return arguments.length?(V=typeof n=="function"?n:Q(+n),i):V},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};